The problem is in your didFinishLaunching
. Where you allocate your view controller -
UIViewController *viewController = [[UIViewController alloc] initWithNibName:@"ViewController" bundle:nil];
You are allocating the base UIViewController
, which doesn't have your clickButton
method - so you get the exception. What you want is -
ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
By omitting the UI you get an instance of your UIViewController subclass, which implements the clickButton
method.