NS_ENUM works without the typedef (sort of)
You may have heard that NS_ENUM works without the typedef (sort of). What I mean by this is that most of the time, it all just works even if you leave off the typedef on something like this:
NS_ENUM(NSInteger, BinaryItemType) { BINARY_ITEM_TYPE_CONTACT_PHOTO = 0, BINARY_ITEM_TYPE_SIGNATURE_DATA, BINARY_ITEM_TYPE_BUSINESS_CARD, }; |
However, if I ran into a situation where I did something to my code base to cause it to start throwing build errors like this:
duplicate symbol _BinaryItemType in: /Users/abc/Library/Developer/Xcode/DerivedData/xyz-bultlvoaxhkekcflkuawzlgzhwyq/Build/Intermediates/xyz.build/Debug-iphonesimulator/xyz.build/Objects-normal/x86_64/XYZViewController.o /Users/abc/Library/Developer/Xcode/DerivedData/xyz-bultlvoaxhkekcflkuawzlgzhwyq/Build/Intermediates/xyz.build/Debug-iphonesimulator/xyz.build/Objects-normal/x86_64/Contact+PDF.o ld: 15 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) |
And of course, I did not realize that the typedef missing was causing this error. As soon as I changed the NS_ENUM to look like this, all went well:
typedef NS_ENUM(NSInteger, BinaryItemType) { BINARY_ITEM_TYPE_CONTACT_PHOTO = 0, BINARY_ITEM_TYPE_SIGNATURE_DATA, BINARY_ITEM_TYPE_BUSINESS_CARD, }; |
BTW, Happy Birthday to Rosalind Chao, who so ably portrayed Keiko O’Brien in Star Trek The Next Generation and Star Trek Deep Space Nine.