1

[Edited with solution below]

I want to call a Parse.com query whenever the app becomes active, so that if it's brought up from the foreground, a new set a data will be called.

I realize there is a method for this in the AppDelegate

- (void)applicationDidBecomeActive:(UIApplication *)application {

}

But I want to know how I can put the query information obtained in my AppDelegate and put it in my ViewController where I can display the information.

Any ideas on what I might do? Or if there is another way to make the query when the app becomes active? Thanks.

So here is what I came up with. I had my method (called getData) in the ViewController, and in the viewDidLoad method, I inserted this code

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getData)

 name:UIApplicationDidBecomeActiveNotification object:nil];

And now it works just as I had hoped. Thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
MScottWaller
  • 3,321
  • 2
  • 24
  • 47

1 Answers1

1

This is a really broad question, but what you can do is you can post a notification and make your view controller listen to it.

Then after your app re enter from background, you can post the notification and in the observer method that you implemented in the view controller, you can pull the data from Parse.

See this question to understand the sequence of the method calls.

Community
  • 1
  • 1
Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156