Reputation: 1531
I'm having trouble by writing and reading the title of UIButton
.
My problem:
// If I execute this line of code everything works fine, the title gets changed in the UI
[self.lastButtonPressed setTitle:stringDate forState:UIControlStateNormal];
// In the next line of code I want to read the title I've set before, but everything I get is the title of the UIButton before I changed the title.
NSString *myText = [self.lastButtonPressed.titleLabel.text];
Is it possible that [UIButton setTitle]
gets called asynchronous? If yes, is there a possibility to make this call synchronous?
Upvotes: 2
Views: 1093
Reputation: 112857
You probably want currentTitle
not titleLabel.text
. Or perhaps titleForState:UIControlStateNormal
.
Upvotes: 6