How do I define and use an ENUM in Objective-C?
Apple provides a macro to help provide better code compatibility, including Swift. Using the macro looks like this.
typedef NS_ENUM(NSInteger, PlayerStateType) { PlayerStateOff, PlayerStatePlaying, PlayerStatePaused};
Your typedef
needs to be in the header file (or some other file that's #import
ed into your header), because otherwise the compiler won't know what size to make the PlayerState
ivar. Other than that, it looks ok to me.
In the .h:
typedef enum { PlayerStateOff, PlayerStatePlaying, PlayerStatePaused} PlayerState;