최신 SDK, Xcode 4.2 및 ARC을 사용하여 iOS 4 응용 프로그램을 개발하고 있습니다.알려진 셀렉터 인스턴스 메서드가 없습니다
나는 appDelegate.h
#import <UIKit/UIKit.h>
@class ViewController;
@class SecondViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UINavigationController* navController;
ViewController* viewController;
SecondViewController* secondViewController;
}
@property (strong, nonatomic) UIWindow *window;
- (void) showSecondViewController;
@end
에 메서드를 추가 한 내가
- (IBAction)goSecondClicked:(id)sender
{
[[[UIApplication sharedApplication] delegate] showSecondViewController];
}
ViewController.m
에 그 방법에 메시지를 보낼 때,
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
구현하지만 것
다음 컴파일러 오류가 발생합니다.
자동 참조 계산 문제 'showSecondViewController'
단서 선택에 대한 알려진 인스턴스 방법은?
은 정말 downvoters는 항상 이유를 설명달라고 ... 최선의 해결책은 아니지만 제 대답이 효과가 있습니다. –