Reputation: 1904
I populate a tableView in my viewDidLoad to get some JSON from my server.
NSURL *theEvents = [NSURL URLWithString:@"http://192.168.1.100:3000/events.json"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:theEvents cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0];
NSHTTPURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
When I debug and run this code it gets live data from the server. If I stop (the debugger) and start again it also works fine and gets live data from the server. However if I:
it does not get the live changed data from the server. I don't understand this. When I quit the app in the simulator via the home button, doesn't the program completely exit? I get the exact same behavior with a phone too.
I want to always get live data from my server in viewDidLoad. What am I doing wrong?
Upvotes: 1
Views: 141
Reputation: 1904
This is exactly what fixed my problem:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wokeUp) name:UIApplicationDidBecomeActiveNotification object:nil];
Upvotes: 1