[英]how to convert Int8 to Uint8 in swift?
var ss = UnsafeMutablePointer<Int8>.allocate(capacity: 20)
var b:Data = Data.init(capacity: 20)
for i in 0...19{
b[i] = UInt8(ss[i])
}
this sentence will not show error utill the ss[i] was bigger than 127.which was a negative number.then it shows an error.这句话不会显示错误,因为 ss[i] 大于 127。这是一个负数。然后它会显示错误。 says it's not allowed to be a negative number.
说它不允许是负数。
how to solve it?如何解决? I'm a newbie of swift.
我是swift的新手。
var b:Data = Data(bytes:ss,count: 20)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.