views:

86

answers:

1

Hi There,

I am trying to have my app reload data when it is brought to the foreground via the applicationWillEnterForeground method. I can get the function to work and write to the NSLog, but I have a function that I want to be called from another class, how would I go about this?

I have tried below:

- (void)applicationWillEnterForeground:(UIApplication *)application {
    //Re-run...
    [MainViewController reRun];
}

Be gentle bit of a newbie...

+1  A: 

You can register to UIApplicationDidBecomeActiveNotification, and reload your data when your receive it.

Benj
Hi Benj, thanks for the response. Could you give me a nudge in the right direction on this?
jimbo
in Your ViewController : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appEnterForeground:) name:UIApplicationDidBecomeActiveNotification object:nil];Then create a method named -(void)appEnterForeground:(NSNotification*)notif in which you do what you want to reload your data.
Benj