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))
}
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))
}
本文标题:swift 中 Data 如何转换C数组
本文链接:https://www.haomeiwen.com/subject/wgvkpxtx.html
网友评论