简体   繁体   English

在基于arm64架构的iOS App上何时应使用'int'?

[英]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.

相关问题 体系结构arm64(iOS)的未定义符号 - Undefined symbols for architecture arm64 (iOS) 架构 arm64 iOS 的未定义符号 - Undefined symbols for architecture arm64 iOS iOS-体系结构arm7,arm64的未定义符号 - iOS - undefined symbols for architecture arm7, arm64 在具有arm64体系结构的64位iOS上运行Wax - Run Wax on 64-bit iOS with arm64 Architecture iOS App需要arm64吗? - iOS App Requires arm64? 体系结构arm64的未定义符号:“ getdefaultgateway(unsigned int *)” - Undefined symbols for architecture arm64: “getdefaultgateway(unsigned int*)” Flutter 应用程序 - 适用于 iOS 设备的架构 arm64 的未定义符号。 Flutter 包 - cryptlib - Flutter app - Undefined symbols for architecture arm64 for iOS Device. Flutter Package - cryptlib 在 iOS 应用程序中链接 static 库后架构 arm64 的未定义符号 - Undefined symbols for architecture arm64 after linking a static library in iOS app 在iOS 7设备中运行时,“ Xcode 6 beta”在文件中缺少“所需的架构arm64 ...” - “Missing required architecture arm64 in file…”Xcode 6 beta when running in ios 7 device 错误:在iOS项目(swift)中嵌入Unity(Vuforia)时,体系结构arm64的符号未定义 - Error: Undefined symbols for architecture arm64 when Embed Unity(Vuforia) in IOS project(swift)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM