0

I've migrated my swift code from swift 3.0 to swift 4.2 using XCode 10.1

I'm then running it my IOS device.

There's a difference between running the code in 10.1 and 10.2.1 in the way CoreBluetooth is reading the characteristic's value back from the BLE Device.

    func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {

    let value = characteristic.value?.hashValue
    timer.invalidate()
    print("HEY value is \(value)")

    if value == 158{ 
     //do stuff

This prints out:

HEY value is Optional(158) //this is the intended value, which appears in xcode 10.1 . 

However when running on 10.2, running the same code base..

HEY value is Optional(-2118798348948658621) //the value runs off 

Just wondering if anyone out there has an idea of what i'm doing wrong or missing out...

Thanks and have a great day!

Andrew Ng
  • 97
  • 1
  • 12

0 Answers0