So I'm using NSClassFromString to check if the user has iOS 5 or iOS 6 installed to use Apple's new iOS 6 MKMapItem. This is the code:
- (void)openDirections:(id)sender {
Class mapClass = NSClassFromString(@"MKMapItem");
if (mapClass == nil) {
// iOS 5, do something here
}
else {
// iOS 6, open up maps with MKMapItem.
}
}
By the code above, when I run it on iOS 5.1 simulator or a iOS 5.1 device, the iOS 6 branch gets run. However, if I use
Class mapClass = NSClassFromString(@"PKPass");
which was also introduced in iOS 6, my code follows the appropriate iOS 5 or iOS 6 branch. Am I missing something? Thanks.