, "" ? ".
, , .
, , , :
1- , , , requestlocationupdates .
2- , , , - , , -:
[self performSelector:@selector(fetchLocationTimeout) withObject:nil afterDelay:LOCATION_LISTEN_TIME];
:
(void)fetchLocationTimeout{
if(!finished){
[self stopUpdatingLocation];
[delegate locationFinished:bestEffortAtLocation];
}
}
3- didupdate- "" , , " ", , :
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
if(newLocation is the best i have){
self.bestEffortAtLocation = newLocation;
}
if (bestEffortAtLocation == nil || newLocation is the best i have) {
if (bestEffortAtLocation is good enough and i want to use it) {
[self stopUpdatingLocation];
SEL selector = NSSelectorFromString(@"fetchLocationTimeout");
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:selector object:nil];
[delegate locationFinished:bestEffortAtLocation];
}
}
}
, , , didupdate, , :
(void)stopUpdatingLocation{
finished = true;
NSLog(@"stopUpdatingLocation! manager: %@", [locationManager description]);
[locationManager stopUpdatingLocation];
locationManager.delegate = nil;
}
: "", , , - , , , . , "locationFinished".
, , .