NSInteger versus int [duplicate]

自闭症网瘾萝莉.ら 提交于 2020-01-03 20:31:29

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/1934719/nsinteger-versus-int

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!