How to stop multiple times method calling of didUpdateLocations() in ios

前端 未结 10 1158
無奈伤痛
無奈伤痛 2020-11-28 06:45

This my code......

 -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
 {

    location_updated = [locations lastObj         


        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 07:21

    The easiest way:

    -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
    {
       [manager stopUpdatingLocation];
        manager.delegate = nil;
    
       //...... do something
    
    }
    

    The manager can't find your didUpdateLocations method without the delegate reference :-D

    But don't forget to set it again before using startUpdatingLocation

提交回复
热议问题