9

I'm using the geocodeAddressString:completionHandler: method, which returns an array of CLPlacemarks. I have to get latitude, longitude, mnemonical name and radius. While getting the first 3 is easy:

double lat = placemark.location.coordinate.latitude;
double lng = placemark.location.coordinate.longitude;
NSString *name = [NSString stringWithFormat:@"%@", ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO)]

I don't know how to get the radius now, as placemark.region.radius is deprecated. Any ideas what to use now instead? I can't find anything interesting enough in documentation.

Nat
  • 12,032
  • 9
  • 56
  • 103
  • New class called CLCircularRegion. https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLRegion_class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instp/CLRegion/radius – danh Jan 09 '14 at 14:57
  • @danh How should i migrate from old region when i'm not initing it? Casting rather won't help and there is no method to transform old region to new circularRegion. – Nat Jan 09 '14 at 15:00

1 Answers1

9

The deprecation note is for radius in CLRegion and it says to use CLCircularRegion instead.

Note that CLCircularRegion is a subclass of CLRegion.
CLCircularRegion has the same properties that CLRegion had (including radius).

This matters if you are the one creating a CLRegion with the intention of using its radius property.


However, here, it is the SDK itself (specifically the geocodeAddressString method) which has to worry about it and handle it.

In iOS 7, that method indeed handles it by returning a CLCircularRegion for the placemark's region property.

Essentially, you don't have to do or change anything here since the property names are identical.

This code will work from iOS 4 to iOS 7:

NSLog(@"radius=%f", placemark.region.radius);
  • 5
    Then i would recommend to use: `[(CLCircularRegion*)placemark.region radius]` to avod extra warning. Thank you for response. – Nat Jan 09 '14 at 15:43
  • 1
    Yes, unfortunately if the Deployment Target is 7.0, it gives that warning. If Deployment Target is less than 7.0 while still using the iOS 7 SDK, there is no warning. –  Jan 09 '14 at 15:58