1

I am using CoreLocation Framework for getting latitude and longitude in my project.

I have implement this delegate method in my .m file

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

   NSLog(@"Locations : %@", locations); 
}

But in iOS 5.0 & 5.1, this method is not call. and in iOS 6.0 or later it's call properly. so how to call this method in iOS 5.0 or later.

ChandreshKanetiya
  • 2,414
  • 5
  • 27
  • 41
  • Duplicate question http://stackoverflow.com/questions/12602463/didupdatelocations-instead-of-didupdatetolocation – Tirth Jul 23 '13 at 05:28

3 Answers3

2

didUpdateLocations: did not exist in ios 5 or earlier. If you want to support those ios version then just use the deprecated didUpdateToLocation:fromLocation. Even though it is deprecated it still works in ios 6 and 7. That's the simplest solution.

You could have delegate methods for both, but that gets more complicated to manage. If you don't need to build track logs in the background then you don't really need didUpdateLocations: it was created to save battery power while collecting multiple points when running in the background.

progrmr
  • 75,956
  • 16
  • 112
  • 147
0

See this answer...This method for iOS 5 (deprecated on iOS 6)and old version.

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
           fromLocation:(CLLocation *)oldLocation

This method for iOS 6 and later version..

- (void)locationManager:(CLLocationManager *)manager 
     didUpdateLocations:(NSArray *)locations
Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66
0

Refer:

http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManagerDelegate_Protocol/CLLocationManagerDelegate/CLLocationManagerDelegate.html

As you can see locationManager:didUpdateLocations: is available only in iOS 6.0 and later.

You can always get the recent updated location from

CLLocationManger's location 

property.

Puneet Sharma
  • 9,369
  • 1
  • 27
  • 33