Reputation: 49
I am fairly new to objective-C and XCode. I am trying to update a text label on the screen,
I call a function loadData
in viewDidLoad
, which works fine. I am trying to print a string that was generated in the loadData
function.
After that string is generated, I use:
self.MyLabel.text=string;
But does not update.
I am using IBOutlet
as well, I think it might be related to different threads but I am not sure.
Any help is appreciated.
Upvotes: 3
Views: 11705
Reputation: 1283
Have you tried updating the label after the
- (void)viewDidLoad {
// call another method before assigning to retrieve the string here.
self.MyLabel.text=string;
}
Sometimes the way the UIViewController
and IB
setup will need you to set in after the viewDidLoad
. Try NSLog(@"%@", self.MyLabel)
at wherever you try to assign to see if its not null
Upvotes: 1
Reputation: 28767
Your statement is correct:
self.mylabel.text = @"Test";
So make sure, that the IBOutlet is correctly connected (filled grey circle).
Check also if the string contains the correct value.
Upvotes: 0