I am working on a Core Bluetooth Application in which I programmed a peripheral device to transmit a heart rate value of 90 beats per minute. On iOS, I have discovered my service and my heart rate characteristic and am now working on processing that data, from the console output, the raw NSData characteristic.value data is 5a000000 which translates to a unsigned 32 bit integer value of 90 beats per minute. What I want to do now is to take that NSData data and turn store it as an unsigned 32 bit value, I found a reference online to the getBytes:length: method on the NSData class, however, I dont understand how that line of code works, and how that data is actually converted to my uint32_t value. Any explanation on how the method works and what is it doing when I provide it my rawData would we helpful!
NSData *rawData = characteristic.value;
uint32_t rawInt = 0;
NSLog(@"rawInt Value Before: %d", rawInt);
// THIS METHOD IS WHAT I DONT UNDERSTAND
// NSLOG VALUES INDICATE THAT THE METHOD IS WORKING SINCE I GOT THE CORRECT HEART RATE VALUE
[rawData getBytes:&rawInt length:sizeof(rawInt)];
NSLog(@"rawInt Value After: %d", rawInt);