在Swift 3中将[UInt8]转换为[UInt32]

时间:2017-04-19 13:53:15

标签: swift

如何在Swift 3中将[UInt8]转换为[UInt32]?

let u8: [UInt8] = [0x02, 0x02, 0x02]

1 个答案:

答案 0 :(得分:4)

试试这个

let u8: [UInt8] = [0x02, 0x02, 0x02]
let u32: [UInt32] = u8.map { UInt32($0)  }
print("u32: \(u32)")