开发者

NSInteger versus int [duplicate]

开发者 https://www.devze.com 2022-12-14 16:22 出处:网络
This question already has answers here: When to use NSInteger vs. int (8 answers) Closed 8 years ago. 开发者_C百科
This question already has answers here: When to use NSInteger vs. int (8 answers) Closed 8 years ago. 开发者_C百科

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消