Swift2.0基本数据类型汇总
2015-12-02 13:05
330 查看
There are a few other fundamental types as well:
•
Double. Similar to a
Float
but with more precision. You will use
Doubles later inthis tutorial for storing
latitude and longitude data. 双精度浮点型
•
Character. Holds just a single character.
A String
is a collection of
Characters. 字符型
•
UInt. A variation on
Int
that you may encounter occasionally. The U stands for “unsigned”, meaning
the type can hold positive values only. It’s called unsigned because it cannot have a negative sign (-) in front of the number.
UInt
can fit numbers between 0 and plus 4 billion but no negative numbers. On a 64-bit device, the upper limit of
UInt
is even higher, a little over 18 quintillion. 无符号整型,只能表示正数
•
Int8,
UInt8,
Int16,
UInt16,
Int32,
UInt32,
Int64,
UInt64. These are all variationson
Int. The difference is in how many bytes
they have available to store theirvalues. The more bytes, the bigger the values can be. In practice you almostalways use
Int, which uses 4 bytes for storage (a
fact that you may immediatelyforget) and can fit whole numbers ranging from minus 2 billion to plus 2 billion.On a 64-bit device,
Int
uses 8 bytes and can store positive and negative numbersup to about 19 decimal digits. Those are big numbers! 高位整型
•
CGFloat. This isn’t really a Swift type,
but a type defined by the iOS SDK. It’s adecimal point number like Float
and
Double. For historical reasons, this
is usedthroughout UIKit for floating-point values. (The “CG” prefix stands for the CoreGraphics framework.) iOS SDK中特有的Float型
•
Double. Similar to a
Float
but with more precision. You will use
Doubles later inthis tutorial for storing
latitude and longitude data. 双精度浮点型
•
Character. Holds just a single character.
A String
is a collection of
Characters. 字符型
•
UInt. A variation on
Int
that you may encounter occasionally. The U stands for “unsigned”, meaning
the type can hold positive values only. It’s called unsigned because it cannot have a negative sign (-) in front of the number.
UInt
can fit numbers between 0 and plus 4 billion but no negative numbers. On a 64-bit device, the upper limit of
UInt
is even higher, a little over 18 quintillion. 无符号整型,只能表示正数
•
Int8,
UInt8,
Int16,
UInt16,
Int32,
UInt32,
Int64,
UInt64. These are all variationson
Int. The difference is in how many bytes
they have available to store theirvalues. The more bytes, the bigger the values can be. In practice you almostalways use
Int, which uses 4 bytes for storage (a
fact that you may immediatelyforget) and can fit whole numbers ranging from minus 2 billion to plus 2 billion.On a 64-bit device,
Int
uses 8 bytes and can store positive and negative numbersup to about 19 decimal digits. Those are big numbers! 高位整型
•
CGFloat. This isn’t really a Swift type,
but a type defined by the iOS SDK. It’s adecimal point number like Float
and
Double. For historical reasons, this
is usedthroughout UIKit for floating-point values. (The “CG” prefix stands for the CoreGraphics framework.) iOS SDK中特有的Float型
相关文章推荐
- 《从零开始学Swift》学习笔记(Day43)——构造函数继承
- 《从零开始学Swift》学习笔记(Day43)——构造函数继承
- [ios][swift]提示框,并自动消失
- [ios][swift]UIButton
- iOS项目开发实战(Swift)—代理的使用
- 【iOS】swift 排序Sort函数用法(包含NSDictionary排序)
- 【iOS】swift 排序Sort函数用法(包含NSDictionary排序)
- Swift UIButton 和 UILabel 的详细解释和创建使用
- 【iOS】swift 让程序挂起后,能在后台继续运行任务
- 【iOS】swift 让程序挂起后,能在后台继续运行任务
- Swift-控制流
- Objecetive-C PK Swift
- Swift - 重要知识点总结
- Swift的一些翻译:tips
- swift初体验
- swift delegate
- Swift 三方库的使用
- Swift-简单值
- 43个优秀的Swift开源项目推荐
- 《swift2.0 官方教程中文版》 第2章-14构造过程