Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between int, NSInteger and NSUInteger

What is the main difference between int, NSInteger and NSUInteger in Objective-C?

Which one is better to use in an application and why?

like image 851
Hitarth Avatar asked Oct 02 '11 12:10

Hitarth


People also ask

What is NSUInteger?

Describes an unsigned integer.

Is NSInteger primitive?

It is not a C primitive (like int, unsigned int, float, double, etc.) NSInteger , CGFloat , NSUInteger are simple typedefs over the C primitives.

What is NSNumber in Objective C?

NSNumber is a subclass of NSValue that offers a value as any C scalar (numeric) type. It defines a set of methods specifically for setting and accessing the value as a signed or unsigned char , short int , int , long int , long long int , float , or double or as a BOOL .


1 Answers

In such cases you might right click and go to definition:

#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 
like image 72
Bastian Avatar answered Oct 02 '22 20:10

Bastian