I am developing an iOS 4 application using the latest SDK, Xcode 4.2 and ARC .
I added the appDelegate.h method
And it is implemented in appDelegate.m
#import "AppDelegate.h" #import "ViewController.h" #import "SecondViewController.h" @implementation AppDelegate @synthesize window = _window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; viewController.title = @"First"; navController = [[UINavigationController alloc] initWithRootViewController:viewController]; self.window.rootViewController = navController; [self.window makeKeyAndVisible]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { ... } - (void)applicationDidEnterBackground:(UIApplication *)application { ... } - (void)applicationWillEnterForeground:(UIApplication *)application { ... } - (void)applicationDidBecomeActive:(UIApplication *)application { ... } - (void)applicationWillTerminate:(UIApplication *)application { ... } - (void) showSecondViewController { secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; secondViewController.title = @"Second"; [navController pushViewController:secondViewController animated:YES]; } @end
But when I send a message to this method in ViewController.m
- (IBAction)goSecondClicked:(id)sender { [[[UIApplication sharedApplication] delegate] showSecondViewController]; }
I get the following compiler error:
Automatic reference counting error There is no known instance method for selector 'showSecondViewController'
Any clue?
source share