In iOS NSUInteger
è un unsigned int
, su OSX è un unsigned long
. Come posso fare una dichiarazione di stampa comeCompila NSLog con unsigned int e unsigned long su iOS e OSX senza avviso
NSLog(@"Array has %d elements.",[array count]);
compile su entrambe le piattaforme senza avviso? Ovviamente posso usare un costrutto #ifdef #else #endif
ma questo aggiungerà 4 linee di codice. Potrei anche trasmettere il valore restituito a unsigned int. C'è una soluzione più breve?
Il modo migliore è 'NSLog (@ "% lu", (unsigned long) array.count);' 'per NSUInteger', e' NSLog (@ "% ld", (lungo) button.tag); 'per' NSInteger': nessun avviso in 32 bit o 64 bit. – NSGod