NSData to [Uint8] in Swift

后端 未结 7 792
无人及你
无人及你 2020-12-04 17:24

I couldn\'t find a solution to this problem in Swift (all of them are Objective-C, and they deal with pointers which I don\'t think exist in Swift in the same form). Is ther

7条回答
  •  春和景丽
    2020-12-04 18:03

    Swift 3/4

    let data = Data(bytes: [0x01, 0x02, 0x03])
    let byteArray: [UInt8] = data.map { $0 }
    

提交回复
热议问题