Crash on iOS 9 only: [MKPlacemark initWithCoordinate:]: unrecognized selector

633 views Asked by At

Code:

-(void)getRouteDirections{
    MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];
    [request setSource:[MKMapItem mapItemForCurrentLocation]];

    // It crashes on this line:      
    MKPlacemark * placemark = [[MKPlacemark alloc]initWithCoordinate:_location.coordinate];
}

Exception:

-[MKPlacemark initWithCoordinate:]: unrecognized selector sent to instance

It crashes only on iOS 9. How can I solve this problem?

1

There are 1 answers

0
Cœur On

Answer from Larme comments:

- (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate; is available since iOS10.

For iOS 9 or earlier, initWithCoordinate:addressDictionary: is available since iOS 3.