Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSInteger versus int [duplicate]

Tags:

nsinteger

What would be the reason to use an NSInteger vs an int in iPhone programming? Thanks.

like image 583
Crystal Avatar asked Mar 08 '26 23:03

Crystal


1 Answers

An NSInteger is just a typedef with the following definition:

#if __LP64__ || NS_BUILD_32_LIKE_64
  typedef long NSInteger;
  typedef unsigned long NSUInteger;
#else
  typedef int NSInteger;
  typedef unsigned int NSUInteger;
#endif

As the typedef is defined differently basing on the platform, you can keep using NSInteger independently from the platform.

like image 137
apaderno Avatar answered Mar 10 '26 15:03

apaderno