In my app I need to present a view controller. The 6.0 method for presenting a view controller is presentViewController:animated:completion:. I want to support 4.3 also. In 4.3 the method to be called is presentModalViewController:animated:. So I use respondsToSelector: to find out whether the method is supported. But when I compile the app for 6.0 it gives warning message as
presentModalViewController:animated: is deprecated: first deprecated in iOS 6.0
Can anyone know how to get rid of this warning. I also do not have 4.3 device to test whether it works. I need to assume that the code I write should work on 4.3.
if([myViewController respondsToSelector:@selector(presentModalViewController:animated:)]){
[myViewController presentModalViewController:anotherViewController animated:YES];
}else{
[myViewController presentViewController:anotherViewController animated:YES completion:nil];
}
you could make check opposite for respondsToSelector
it might help, and this is the way to go actually if you are supporting older versions:)
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
[self presentViewController:anotherViewController animated:YES completion:nil];
} else {
[self presentModalViewController:anotherViewController animated:YES];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With