In Cocoa do you favor NSInteger or int, and also why?
NSUInteger are Cocoa - specified substitutes for the normal constructed - in types.
Exists any kind of advantage to making use of the NS * types over the constructed - ins? Which do you favor and also why? Are
NSInteger and also
int the very same size on 32 - little bit/ 64 - little bit systems?
The means I recognize it is that NSInteger et al. are style secure variations of the equivalent C types. Primarily their dimension differ relying on the style, yet NSInteger, as an example, is assured to hold any kind of legitimate reminder for the existing style.
Apple advises that you make use of these to collaborate with OS X 10.5 and also onwards, and also Apple is API :s will certainly utilize them, so it is most definitely an excellent suggestion to get involved in the behavior of utilizing them. They call for a little bit extra keying, yet in addition to that it does not appear to be any kind of factor not to utilize them.
64 - little bit is in fact the raison d'être for NSInteger and also NSUInteger ; prior to 10.5, those did not exist. Both are merely specified as longs in 64 - little bit, and also as ints in 32 - little bit :
#if __LP64__ || NS_BUILD_32_LIKE_64 typedef long NSInteger; typedef unsigned long NSUInteger; #else typedef int NSInteger; typedef unsigned int NSUInteger; #endif
Thus, utilizing them instead of the extra standard C types when you desire the 'little bit - indigenous' dimension.