In my iOS application, I'm having a UITableView inside my UIViewController. After data loading completed to the UITableView, when I press the Home button of the iPhone, the application will enter to the background. It will execute following method.
- (void)applicationDidEnterBackground:(UIApplication *)application {
When I tap on the application icon and launch the app, it will call following methods in AppDelegate
- (void)applicationWillEnterForeground:(UIApplication *)application {
and
- (void)applicationDidBecomeActive:(UIApplication *)application {
but none UIViewController methods. Therefore what I did was, called a custom method created by myself which is located inside my UIViewController class like below. This code go inside applicationDidBecomeActive method.
MyViewController *tViewCont = [MyViewController alloc];
[tViewCont remindToPopulate];
I put a log message and confirmed that remindToPopulate method is executing. Inside that method I want to reload the UITableView.
But at this time the UITableView property that I've declared is set to nil. What is the proper way of saving that UITableView property and load it back with the latest data?
For that you can add notification for
UIApplicationDidBecomeActiveNotification
orUIApplicationWillEnterForegroundNotification
in viewDidLoad in controller.just add
and in yourmethod
you can also add
UIApplicationWillEnterForegroundNotification
notification. add as per your need.