bursyllac bursyllac - 1 year ago 81
iOS Question

Can I use an enum as a property in Objective C

I saw it is customed to use a boolean property as a flag. something like that:

@property (nonatomic) BOOL commaAlreadyIntroduced;

I need something like that but with at least 3 or 4 states.

Can I use an enum?

The standalone enum should look like:

typedef enum stackState{
empty, oneOperand, operandAndOperator, fullStack

Answer Source

Yes, it's not a problem:

@property (nonatomic, assign) stackState yourIvar;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download