Reputation: 413
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
}stackState;
Upvotes: 31
Views: 22699
Reputation: 520
@property (nonatomic, assign) enum stackState stackStateVar;
Without 'enum' added, my unit tests kept showing errors.
Upvotes: 8
Reputation: 7344
Yes, it's not a problem:
@property (nonatomic, assign) stackState yourIvar;
Upvotes: 63
Reputation: 5114
@property (nonatomic, assign) enum stackState yourIvar;
(was getting errors until I added enum)
Upvotes: 3