I wat to do something like this:
if (viewController.mapView) [viewController.mapView someMethod];
However, if mapView is not a class variable, this crashes. How do I check if mapView exists?
I wat to do something like this:
if (viewController.mapView) [viewController.mapView someMethod];
However, if mapView is not a class variable, this crashes. How do I check if mapView exists?
Oops, found it:
if ([vc respondsToSelector:@selector(mapView)]) {
[[vc mapView] viewWillAppear:YES];
}
For ordinary selectors, you can use respondsToSelector:
. I'm not certain if this will work for new-style property access (as it appears you are using in this example). To test if a class responds to a given selector, use instancesRespondToSelector:
.