Create a viewDidLoad method similar to this for HomeViewController
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourUpdateMethodGoesHere:) name:UIApplicationWillEnterForegroundNotification object:nil]; }
If your ViewController is a tableViewController, you can also directly call the reload data function:
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:[self tableView] selector:@selector(reloadData) name:UIApplicationWillEnterForegroundNotification object:nil]; } - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; }
Or you can use the block:
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { [[self tableView] reloadData]; }];
Tieme source share