美文网首页
int和NSInteger有什么区别?

int和NSInteger有什么区别?

作者: 知本集 | 来源:发表于2017-04-05 15:43 被阅读99次

首先:

在c语言中,int和long的字节数是和操作系统指针所占位数相等;

但c语言中说,long的长度永远大于或等于int;

objective-c里,苹果的官方文档中总是推荐用NSInteger;

区别:

原来在苹果的api实现中,NSInteger是一个封装,它会识别当前操作系统的位数,自动返回最大的类型。

总结:

NSInteger与int的区别是NSInteger会根据系统的位数(32or64)自动选择int的最大数值(int or long)还有就是他和NSString一样都可以是对象。

相关文章

  • int和NSInteger有什么区别?

    首先: 在c语言中,int和long的字节数是和操作系统指针所占位数相等; 但c语言中说,long的长度永远大于或...

  • NSUInteger、NSInteger、int

    NSUInteger、 NSInteger 、 int int和NSInteger其实差不多,推荐使用NSInte...

  • NSInteger和int的差别

    NSInteger和int的差别:NSInteger会根据系统的位数32or64,自动选择int的最大数值int ...

  • int和NSInteger区别

    查到c语言中,int和long的字节数是和操作系统指针所占位数相等。 但c语言中说,long的长度永远大于或等于i...

  • int和NSInteger、NSUInteger

    NSUInteger是无符号的,即没有负数NSInteger是有符号的,所以NSUInteger类型不能给它赋负值...

  • int和NSInteger区别

    今天在困惑int和long的使用。 查到c语言中,int和long的字节数是和操作系统指针所占位数相等。 但c语言...

  • NSUInteger和NSInteger和int

    int和NSInteger其实是差不多的,但更推荐使用NSInteger,因为使用NSInteger,这样就不用考...

  • NSInteger 是什么

    先看源代码 int、 NSInteger、 NSUInteger、NSNumber之间的区别和联系int : 当使...

  • int、NSInteger、NSUInteger

    int、NSInteger区别 NSInteger会自动识别当前设备系统是32位还是64位,自动选择int的最大数...

  • 5.int,NSInteger,NSNumber

    1.int是C 数据类型,NSInteger是OC 数据类型,推荐使用NSInteger,NSInteger会根据...

网友评论

      本文标题:int和NSInteger有什么区别?

      本文链接:https://www.haomeiwen.com/subject/ucfxattx.html