【发布时间】:2017-08-23 11:18:42
【问题描述】:
因为我将我的代码转换为 Swift 3,所以发生了错误。
'init is unavailable: use 'withMemoryRebound(to:capacity:_)' to temporarily view memory as another layout-compatible type.
这是我的代码:
func parseHRMData(data : NSData!)
{
var flags : UInt8
var count : Int = 1
var zw = [UInt8](count: 2, repeatedValue: 0)
flags = bytes[0]
/*----------------FLAGS----------------*/
//Heart Rate Value Format Bit
if([flags & 0x01] == [0 & 0x01])
{
//Data Format is set to UINT8
//convert UINT8 to UINT16
zw[0] = bytes[count]
zw[1] = 0
bpm = UnsafePointer<UInt16>(zw).memory
print("HRMLatitude.parseData Puls(UINT8): \(bpm)BPM")
//count field index
count = count + 1
}
我该如何解决这个错误?
提前致谢!
【问题讨论】:
标签: swift swift3 unsafe-pointers