Skip to content

Instantly share code, notes, and snippets.

@mattjgalloway
Created September 26, 2013 13:10
Show Gist options
  • Save mattjgalloway/6713937 to your computer and use it in GitHub Desktop.
Save mattjgalloway/6713937 to your computer and use it in GitHub Desktop.
Always remember what a BOOL is
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, MyEnum) {
MyEnumA = 1 << 0,
MyEnumB = 1 << 1,
MyEnumC = 1 << 2,
MyEnumD = 1 << 3,
MyEnumE = 1 << 4,
MyEnumF = 1 << 5,
MyEnumG = 1 << 6,
MyEnumH = 1 << 7,
MyEnumI = 1 << 8,
};
BOOL isISet(MyEnum e) {
return e & MyEnumI;
}
int main(int argc, char *argv[]) {
@autoreleasepool {
MyEnum e = MyEnumI;
BOOL a = isISet(e);
NSLog(@"isISet = %@", a ? @"YES" : @"NO");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment