Reputation: 4516
In an Objective-C class I have a @private ivar that uses an enum of the form:
typedef NS_ENUM(NSInteger, PlayerStateType) {
PlayerStateOff,
PlayerStatePlaying,
PlayerStatePaused
};
However, I include this definition in the header file of that class (since it's used in it). This effectively makes the type public, which isn't what I intended. How can I make this enum type private?
Upvotes: 3
Views: 2855
Reputation: 23278
Adding my comment as an answer.
You can add this in your .m class so that while importing it is not shared with other classes. You can just add it below your import statements. If the params of this type are used only in this .m class, you can declare that also in this .m file.
Your .m class will look like,
typedef NS_ENUM(NSInteger, PlayerStateType) {
PlayerStateOff,
PlayerStatePlaying,
PlayerStatePaused
};
@interface ViewController () //Use an extension like this in .m class
@property (nonatomic) PlayerStateType param;
@end
Upvotes: 6
Reputation: 4805
Define it in .m file & declare your privare ivar in controller category in .m file. To know about controller category take a look at Difference between @interface definition in .h and .m file.
Upvotes: 1