Reputation: 143
How to forward declare NS_OPTIONS in Objective-C?
Related SO question for NS_ENUMS: Forward-declare enum in Objective-C
Unanswered question on Apple Dev Forum: https://forums.developer.apple.com/thread/16305
typedef NS_OPTIONS(NSInteger, MSSOption) {
MSSOptionNone = 0,
MSSOptionName = 1 << 0,
MSSOptionEmail = 1 << 1,
MSSOptionTelephone = 1 << 2
};
Upvotes: 5
Views: 865
Reputation: 38717
Strictly the same as for NS_ENUM, so the answers from Forward-declare enum in Objective-C are all valid.
To forward declare your NS_OPTIONS, you have two solutions:
typedef NS_ENUM(NSInteger, MSSOption);
typedef NS_OPTIONS(NSInteger, MSSOption);
Both solutions work fine. Tested with Xcode 9.3.1 and Xcode 10.1.
Demonstration at https://github.com/Coeur/StackOverflow50499172.
Upvotes: 5