swift 中 Data 如何转换C数组
2017-11-05 本文已影响0人
天涯何苦sky
Data 到 C数组
- 新的方法
let data = "foo".data(using: .utf8)!
let buff = [UInt8](data)
- 老的方法
let data = "foo".data(using: .utf8)!
let array = data.withUnsafeBytes{
([UInt8](UnsafeMutablePointer)(start: $0, cout: data.count))
}