iosobjective-ccllocationcoordinate2d

How to Convert NSValue to CLLocationCoordinate2D


How to convert NSValue to CLLocationCoordinate2D?

I receive NSValue in (NSArray *)coordinateArray and need to get CLLocationCoordinate2D for each NSValue in array.


Solution

  • Obj-C

    #import <MapKit/MKGeometry.h> 
    
    NSValue *coordinateValue; 
    CLLocationCoordinate2D coordinate = [coordinateValue MKCoordinateValue];
    

    Swift 4.x

    let coordinateValue: NSValue = NSValue.init()
    let coordinate: CLLocationCoordinate2D = coordinateValue.mkCoordinateValue