I have a struct
typedef struct {
int8_t foo : 1;
} Bar;
I have tried to append the bytes to a NSMutableData object like so:
NSMutableData* data = [[NSMutableData alloc] init];
Bar temp;
temp.foo = 1;
[data appendBytes:&temp.foo length:sizeof(int8_t)];
But I receive an error of Address of bit-field requested. How can I append the bytes?
Point to the byte, mask the needed bit, and append the variable as a byte: