The original notation, which gets the result of the first return, then stops updating the latitude and longitude
-(void) Operationlocations: (Nsarray *) locations{ [Self.locationmanager stopupdatinglocation]; .... ....} -(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) Locations [self Operationlocations:locations];}
Conjecture: The Locationmanager positioning callback will be repeated several times, and several corrections. So, if it's the last time, it's the most accurate.
Learned:
Delay 0.2s execution, and if there is a new task, cancel the original task. Eventually, only the last task is performed.
[[] self   class]  Cancelpreviousperformrequestswithtarget self   selector: @selector todosomething: ) object: sender ];
[ self performselector:@selector(todosomething:) withobject: Sender afterdelay: 0.2f];
So the new wording is as follows:
-(void) Operationlocations: (Nsarray *) locations{ [Self.locationmanager stopupdatinglocation]; .... ....} -(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations{ [[Self class ] Cancelpreviousperformrequestswithtarget:self selector: @selector (operationlocations:) object:locations]; [Self performselector: @selector (operationlocations:) withobject:locations afterdelay:0.2f];}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Locationmanager positioning address is not allowed, to obtain a more accurate callback method