Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
Created November 4, 2013 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonwhitaker/7301972 to your computer and use it in GitHub Desktop.
Save simonwhitaker/7301972 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
typedef NS_OPTIONS(uint32_t, SomeOption) {
SomeOptionNone = 0,
SomeOptionFoo = 1 << 0,
SomeOptionBar = 1 << 1,
};
int main(int argc, char *argv[]) {
@autoreleasepool {
SomeOption o = SomeOptionFoo|SomeOptionBar;
NSLog(@"o = %u", o);
}
}
@danielctull
Copy link

So it seems to be a definite this value doesn't exist in the enum list warning.

For example if we add to Simon's example:

typedef NS_OPTIONS(uint32_t, SomeOption) {
    SomeOptionNone = 0,
    SomeOptionFoo = 1 << 0,
    SomeOptionBar = 1 << 1,
    SomeOptionBaz = 1 << 2,
    SomeOptionAll = (SomeOptionBar | SomeOptionFoo | SomeOptionBaz)
};

doing:

SomeOption option = (SomeOptionBar | SomeOptionFoo | SomeOptionBaz);

is fine, while

SomeOption option = (SomeOptionBar | SomeOptionFoo);

yields the same warning as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment