NSUInteger
and NSInteger
can be used even in iOS as well as in OSX.
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
iOS are 32 bit device whereas OSX is 64 bit(Earlier OSX were 32 bit and even you can opt to make an application for 32 bit OS), therefore it contains an if-else directive
based on which it is set.
In OSX I always use %ld
with NSInteger
but in iOS it has to be %d
.
If you use %d
for NSInteger
it shows the warning Loses integer precision.