The following code does work, but it still makes me frustated because in the else block the deprecated method call leads to a warning.
if ([self.navigationController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)])
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
else
{
//Here,the warning goes!
//dismissModalViewControllerAnimated is deprecated
[self.navigationController dismissModalViewControllerAnimated:YES];
}
How can I hide the warning dismissed, or is there any other way to solve the problem?
You can temporarily disable deprecation warnings around the line of code in question: