Swift中的指针类型分为两种:Typed Pointers和Raw Pointers
Typed Pointers叫做类型的指针,他是指向特定类型内存的指针分别是UnsafePointer<T>和UnsafeMutablePointer<T>
Raw Pointers为原始指针,未指明指向的类型,相当于C语言中的void *
- 指针中含Mutable的为可变类型指针,表明可对指针指向的内存进行写操作
- 指针中含Buffer的为缓冲类型指针,这类指针遵守了Sequence和Collection协议,可以方便的进行一些集合操作,如fliter、map、reduce
OC
@property (nonatomic, assign) Byte byteValue //单byte值
@property (nonatomic, assign) Byte *byteArray//byte数组
Swift
let byte = UInt8(0) //单byte值
let bytes = [UInt8](data) //byte数组
let pointer: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer(&bytes)//指针取值