Created
October 26, 2013 22:55
-
-
Save eito/7175555 to your computer and use it in GitHub Desktop.
deferred updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error { | |
NSLog(@"%s -- error: %@", __PRETTY_FUNCTION__, error); | |
_deferring = NO; | |
} | |
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { | |
NSLog(@"%s -- %d locations", __PRETTY_FUNCTION__, locations.count); | |
[self.locationUpdates addObject:locations]; | |
[self.tableView reloadData]; | |
} | |
-(void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager { | |
NSLog(@"%s", __PRETTY_FUNCTION__); | |
} | |
-(void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager { | |
NSLog(@"%s", __PRETTY_FUNCTION__); | |
} | |
-(BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager { | |
return YES; | |
} | |
- (void)enterringBackground { | |
NSLog(@"%s", __PRETTY_FUNCTION__); | |
if (![CLLocationManager deferredLocationUpdatesAvailable]) { | |
NSLog(@"NO DEFERRED LOCATION AVAILABLE"); | |
return; | |
} | |
if (!_deferring) { | |
NSLog(@"Deferred location available"); | |
[self.locationManager allowDeferredLocationUpdatesUntilTraveled:CLLocationDistanceMax timeout:CLTimeIntervalMax]; | |
_deferring = YES; | |
} | |
} | |
- (void)enterringForeground { | |
NSLog(@"%s", __PRETTY_FUNCTION__); | |
[self.tableView reloadData]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying with this code, thanks before.
I will leave a comment after I see a result when running in backround