Swift 2.1 中的字节数据类型
Byte data type in Swift 2.1
我记得 Swift 中有一个 Byte 数据类型,但我已经有大约六个月没有做过任何 Swift 编程了。
现在当我在 iOS 游乐场写作时:
//: Playground - noun: a place where people can play
var str = [Byte]
我得到一个错误:Use of unresolved identifier 'Byte'
我一直在谷歌上搜索,找不到任何关于 Byte 数据类型的文档,但我很确定我以前用过它。
怎么回事?
现在,您不能使用这种类型的数据,实际上它是 8 位 UInt8
类型的另一个名称,现在您必须使用 UInt8
来自MacTypes.h
:
...
/*********************************************************************************
Old names for types
*********************************************************************************/
typedef UInt8 Byte;
...
它是 UInt8
类型的旧名称
我记得 Swift 中有一个 Byte 数据类型,但我已经有大约六个月没有做过任何 Swift 编程了。
现在当我在 iOS 游乐场写作时:
//: Playground - noun: a place where people can play
var str = [Byte]
我得到一个错误:Use of unresolved identifier 'Byte'
我一直在谷歌上搜索,找不到任何关于 Byte 数据类型的文档,但我很确定我以前用过它。
怎么回事?
现在,您不能使用这种类型的数据,实际上它是 8 位 UInt8
类型的另一个名称,现在您必须使用 UInt8
来自MacTypes.h
:
... /********************************************************************************* Old names for types *********************************************************************************/ typedef UInt8 Byte; ...
它是 UInt8
类型的旧名称