On iOS NSUInteger
is a unsigned int
, on OSX it is a unsigned long
. How can I make a print statement like
NSLog(@"Array has %d elements.",[array count]);
compile on both platforms without a warning? I can of course use an #ifdef #else #endif
construct but that will add 4 lines of code. I could also cast the return value to unsigned int. Is there a shorter solution?
How about a cast up to the larger of the two?
NSLog(@"Array has %ld elements.",(unsigned long)[array count]);
No warning in iOS, and I think it's a no-op in OSX.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With