Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

objc read bytes from (and write bytes to) NSData

in Questions Posts: 535

Can you read the data from a NSData array somehow? Haven't figured out how yet. Would be nice to be able to use string.unpack and string.pack to read and write NSData.

I've been able to read the heart rate from my PineTime watch, but not been able to read the NSData value.

Tagged:

Comments

  • edited April 29 Posts: 412
    @tnlogy The only way I've found to write bytes into one was to initialise the NSData from a file. Certainly not ideal but it works. I suspect you could write the data out to a file with the NSData write function and then read it back with Lua's io.open().
  • Posts: 535
    @Steppers ouch, that was cumbersome. I hope s future Codea release might make it easier.
  • Posts: 535
    Figured out that you can convert it to base64 and then read it in Codea. Some more code is available in the thread about bluetooth.

    ~~~
    d = objCBCharacteristic.value:base64EncodedStringWithOptions_()
    st = base64.decode(d)
    ~~~
Sign In or Register to comment.