什么是Swift 2+相当于这一行代码

时间:2016-03-04 04:30:11

标签: ios swift

this answer中找到的这行代码的Swift 2+等价物是多少?

 let a:UInt16 = UInt16(bytes[0]) * 256 + UInt16(bytes[1])  

1 个答案:

答案 0 :(得分:3)

通过检查该链接..首先,您必须定义像[UInt8]

这样的字节数组
   let bytes:[UInt8] = [0x01, 0x02]
   let a = UInt16(bytes[0]) * 256 + UInt16(bytes[1])
相关问题