foobar
foobar

Reputation: 143

Forward-declare ns_options in Objective-C

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

Answers (1)

Cœur
Cœur

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:

solution 1

typedef NS_ENUM(NSInteger, MSSOption);

solution 2

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

Related Questions