I am building an application that is using Mapkit. I know that this is only available in IOS6.
So I should check if this is available or not. I am using the following code.
if(NSClassFromString(@"MKMapKit")) {
// MKMapKit is available in this OS
CLLocationCoordinate2D coords =
CLLocationCoordinate2DMake(51.097185,5.621653);
NSDictionary *address = @{
(NSString *)kABPersonAddressStreetKey: @"Weg naar oqdffds 59",
(NSString *)kABPersonAddressCityKey: @"Msfsf",
(NSString *)kABPersonAddressStateKey: @"Limbusqfqsdf",
(NSString *)kABPersonAddressZIPKey: @"3670",
(NSString *)kABPersonAddressCountryCodeKey: @"BE",
(NSString *)kABPersonPhoneMainLabel:@"04741234567"
};
MKPlacemark *place = [[MKPlacemark alloc]
initWithCoordinate:coords addressDictionary:address];
MKMapItem *mapItem = [[MKMapItem alloc]initWithPlacemark:place];
mapItem.phoneNumber = @"0141343252";
//current location
MKMapItem *mapItem2 = [MKMapItem mapItemForCurrentLocation];
NSArray *mapItems = @[mapItem, mapItem2];
NSDictionary *options = @{
MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
MKLaunchOptionsMapTypeKey:
[NSNumber numberWithInteger:MKMapTypeStandard],
MKLaunchOptionsShowsTrafficKey:@YES
};
[MKMapItem openMapsWithItems:mapItems launchOptions:options];
}else {
NSLog(@"tot hier");
// MKMapKit is not available in this OS
locationController = [[MyCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingLocation];
}
But for some reason or another it always use the google method.
Can anybody help!
As already mentioned, MapKit has been available well before iOS 6.
What you want to check for is
MKMapItem(not “MKMapKit”).However, as the documentation for
MKMapItemexplains (with a code example):So this check:
should be:
or: