在Swift中处理UnsafePointer的EXC_BAD_ACCESS

时间:2017-10-18 15:01:46

标签: swift bluetooth-lowenergy

我如何处理EXC_BAD_ACCES

这是我的代码:

func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
    if characteristic.uuid.uuidString == "9953240D-41CF-4F4E-8C82-EE75E6D43B6B" {
        let value = characteristic.value!.withUnsafeBytes { (pointer: UnsafePointer<Int>) -> Int in
            return pointer.pointee
    }
    print ("VALUE 1: \(value)")
}
  

线程1:EXC_BAD_ACCESS(代码= 1,地址= 0xbad0)在行&#34;返回pointer.pointee&#34;

0 个答案:

没有答案