为了更容易为 64 位架构编写代码,苹果在不久前引入了 NSInteger
或 NSUInteger
数据类型。此数据类型在基础框架中声明。所以基本上,如果我想使用基本的基础框架编写干净的 64 位代码,我可以轻松完成。如果我想使用 float 64 位 aka CGFloat
,就会出现问题。据我所知,在 CGFloat
的情况下,所有几何函数、结构等都旨在与用户界面相关使用,我不明白为什么需要导入 UIKit 框架。这是苹果方面的疏忽吗?是故意的吗?基础中是否有等同于 CGFloat
的东西?
最佳答案
查看 64-Bit Transition Guide for Cocoa Touch .
CGFloat
changes size in 64-bit code. TheCGFloat
type changes to a 64-bit floating point number. As with the NSInteger type, you cannot assume thatCGFloat
is a float or a double. So useCGFloat
consistently.
NSInteger
、NSUInteger
、CGFloat
- 这些在 64 位系统上为 64 位,在 32 位系统上为 32 位.
关于ios - Foundation 框架中未定义 CGFloat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24700245/