Jacob Clark
Jacob Clark

Reputation: 3447

UILabel not updating programmatically

I am attempting to update a UILabel when a user 'Logs In' to my app. I have placed a UILabel onto my Storyboard but it doesn't appear to update, my code is as follows

ViewController.h

@interface ViewController : UIViewController{    
     IBOutlet UILabel *followersCount;
}

@property(nonatomic, retain) IBOutlet UILabel *followersCount;

@end

I then have an action that connects to a REST API via HTTP and it returns a string, if the string is true a user has logged in, so I want to log that users 'followers' to the label, so I use the code:

ViewController.m

followersCount.text = @"Hello World";

But I get the default 'Label' text and not the 'Hello World' as expected

Upvotes: 0

Views: 145

Answers (1)

user1525984
user1525984

Reputation:

Check if the Label Outlet is correctly connected to the Label on you .xib or storyboard file...

If it is, try adding self before the label's name:

self.followersCount.text = @"Hello World";

Upvotes: 2

Related Questions