I have a fair amount of string format specifiers in NSLog / NSAssert etc. calls which use %d
and %u
with NSInteger (= int on 32bit)
an
I think the safest way is to box them into NSNumber
instances.
NSLog(@"Number is %@", @(number)); // use the highest level of abstraction
This boxing doesn't usually have to create a new object thanks to tagged pointer magic.
If you really don't want to use NSNumber
, you can cast primitive types manually, as others suggested:
NSLog(@"Number is %ld", (long)number); // works the same on 32-bit and 64-bit