标签: ios swift
this answer中找到的这行代码的Swift 2+等价物是多少?
Swift 2+
let a:UInt16 = UInt16(bytes[0]) * 256 + UInt16(bytes[1])
答案 0 :(得分:3)
通过检查该链接..首先,您必须定义像[UInt8]
[UInt8]
let bytes:[UInt8] = [0x01, 0x02] let a = UInt16(bytes[0]) * 256 + UInt16(bytes[1])