Difference between writeValue data as NSData in Objective C and Data in Swift

I'm writing to a CoreBluetooth device using

- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type;

in objective C

I would like to move this code over to Swift. Therefore I'm writing using

 open func writeValue(_ data: Data, for characteristic: CBCharacteristic, type: CBCharacteristicWriteType)

All of the parameter values being sent are the same except data when sent as NSData will be represented as such <000a0302>. In Swift the data is represented as

▿ 4 bytes - count : 4 ▿ pointer : 0x00000002810ce5b0 - pointerValue : 10755040688 ▿ bytes : 4 elements - 0 : 0 - 1 : 10 - 2 : 3
  • 3 : 2

However I am not getting the same result back from the bluetooth peripheral - what is the difference between the two examples?

#objective-c #arrays

1 Likes2.45 GEEK