Skip to content

Instantly share code, notes, and snippets.

@jeradesign
Created October 2, 2014 04:59
Show Gist options
  • Save jeradesign/3ad3b1490758af958d29 to your computer and use it in GitHub Desktop.
Save jeradesign/3ad3b1490758af958d29 to your computer and use it in GitHub Desktop.
#define BIT1 0x01
#define BIT2 0x02
#define BIT3 0x04
// ...
unsigned char value = 0;
if (flag1) {
value += BIT1;
}
if (flag2) {
value += BIT2;
}
if (flag3) {
value += BIT3;
}
NSData *data = [NSData dataWithBytes:&value length:1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment