1

I am using core location my development target is 5.0 below is my code to start updating

    self.locationManager = [[CLLocationManager alloc]init];
    [self.locationManager setDelegate:self];
    [self.locationManager startUpdatingLocation];

Below is the delegate method

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
     // Do Something Here
}

It called in iOS 5.0 and 6.0 but got deprecated in iOS 7.0 onward So for iOS 7.0 and above I have to used below

- (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray *)locations
{
    // Do Something Here
}

My question is would I have to manage two separate delegate method for below 7.0 and above 7.0 iOS?

If not than please explained me in detail.

Mohammed Ebrahim
  • 849
  • 1
  • 12
  • 22

2 Answers2

1

Please Read this document here -

To make this compatible with iOS 5 call the newer version of the method inside this funtion

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

http://www.devfright.com/how-to-make-didupdatelocations-compatible-with-ios-5-and-ios-6/

ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48
Aniket Bochare
  • 427
  • 2
  • 10
0

Set your developement target to say iOS 5.0. If that's the case, these warnings will not appear. You can work with the deprecated delegates as the compiler being used doesn't know about the deprecations. Now there may be a case where you need to include this source code in future projects. Those projects might support only iOS7 and above. If that's the case, its always safe to work with both the delegates to avoid problems.

You can also turn off warnings using #pragma like so:

// pre-iOS6.0
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    [self dismissModalViewControllerAnimated:YES];
#pragma clang diagnostic pop

For more information, check out this post: deprecated warnings in xcode and how to handle deprecation

Community
  • 1
  • 1
Anil
  • 2,430
  • 3
  • 37
  • 55