No visible @interface for 'ViewController' declares the selector 'presentModalViewController:animated:completion:'

ios, objective-c

Solution

The problem is `presentmodalviewcontroller:` is deprecated. Use `presentViewController:animated:completion:` instead. Your code:

[self presentViewController:pSearchViewController animated:YES completion:nil];

Problem

I'm using this code to switch view controllers programmatically. When I build and run, I get this error: No visible `@interface` for `ViewController` declares the selector `presentModalViewController:animated:completion:` Code: ``` [self presentModalViewController:pSearchViewController animated:YES completion:nil]; ``` If I get rid of completion:nil then I get the warning `presentModalViewController:animated` is deprecated: first deprecated in iOS 6.0. What do I do?

Original source