Reputation: 13
I have the next enum
:
typedef enum {
SignUp,
LogIn
} TypeAction;
and after property in interface:
@property (assign, nonatomic) TypeAction * typeAction;
In button action I do:
- (IBAction)SignUp:(id)sender {
self.typeAction = SignUp;
}
So, in another button action I try to compare as:
- (IBAction)Check:(id)sender {
if(self.typeAction = SignUp){
//
}
}
But I get nil in
self.typeAction`
Upvotes: 0
Views: 277
Reputation: 1203
This should probably be:
- (IBAction)Check:(id)sender {
if(self.typeAction == SignUp){
//
}
}
or, actually, you might want to change the if
-statement to if(SignUp == self.typeAction)
, because the compiler would catch the ==
problem.
And your property declaration should be:
@property (assign, nonatomic) TypeAction typeAction;
assign
s are not pointers, and you were setting self.typeAction
to SignUp
in that line of the if
statement, which is then read as nil
because it was seeing self.typeAction
as a pointer, which is what was causing the error.
Upvotes: 3