Reputation: 12659
I have NSSTring variable declared in my .h file
@property (nonatomic, retain) NSString *currencyCode;
In my .m file I'm trying to set this variable using following method:
-(void)setCurrencyCode:(NSString *)code {
self.currencyCode = code;
[currencyButton setTitle:currencyCode forState:UIControlStateNormal];
}
Program loops on self.currencyCode = code;
currencyCode
is nil and code
isn't
What is happening here?
Upvotes: 0
Views: 56
Reputation: 12782
You don't need to implement this. Synthesize it. Set the UI label in an IBAction method or another method.
Upvotes: 0
Reputation: 80271
self.currencyCode = x;
is a synonym for
[self setCurrencyCode:x];
So you are calling the setter in an infinite loop. Use this instead:
_currencyCode = code;
Upvotes: 5