[英]When should we use 'int' on iOS App based on arm64 architecture?
What is the advantage of using 'int' on arm64 architecture? 在arm64体系结构上使用'int'有什么优势?
Since Apple forces apps using arm64 on next February, and it suggests us using NSInteger, most of value we will probably be 8 bytes, like size_t, time_t, etc. And also, most apps face no memory issue. 由于Apple于明年2月强制使用arm64的应用程序,并且建议我们使用NSInteger,因此大多数值我们可能为8个字节,例如size_t,time_t等。而且,大多数应用程序都不会遇到内存问题。 Except for adopting data from or to other APIs using 'int', it seems there are little chance we use 'int', is that right?
除了使用'int'从其他API接收数据或向其他API接收数据之外,我们使用'int'的机会似乎很少,对吗?
More questions, is using 'int' be more efficient, saving more memory than 'long' in arm64? 还有更多问题,在arm64中使用'int'是否更有效,比'long'节省更多内存?
I don't think you need int for consuming API's. 我认为您不需要int就可以使用API。
You can use an NSNumber property. 您可以使用NSNumber属性。
@property (nonatomic, copy) NSNumber *number;
You can get Integer value of NSNumber like this: 您可以这样获取NSNumber的Integer值:
[number intValue];
You should try and stay away from using primitive data types like int, unsigned int, long, etc as their size is dependent on the current architecture of the platform. 您应该尝试避免使用基本数据类型,例如int,unsigned int,long等,因为它们的大小取决于平台的当前体系结构。 Instead you should use typedef'd datatypes like NSInteger, uint8_t, size_t as their size will always be consistent on different architectures.
相反,您应该使用类型定义的数据类型,例如NSInteger,uint8_t,size_t,因为它们的大小在不同体系结构上始终是一致的。 Then use which ever datatype is suitable for the current situation.
然后使用适合当前情况的数据类型。
Note that for NSInteger and NSUInteger the size of the datatype is 32 bits on a 32-bit architecture and 64 bits on a 64-bit architecture. 请注意,对于NSInteger和NSUInteger,数据类型的大小在32位体系结构上为32位,在64位体系结构上为64位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.