Locationmanager positioning address is not allowed, to obtain a more accurate callback method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.