[英]Expected getter method not found, Xcode iOS
我正在使用MacOS 10.7(Lion)的Apple最新Xcode。 我正在嘗試制作iPhone應用程序。 我是該語言的新手,因此決定加載Apple指南。 “您的第一個iOS應用程序”。 很好,教了我一些東西,但是沒有用。 我在'TestAppDelegate *'類型的對象上找不到預期的Getter方法
我該如何解決?
這是代碼:
TestAppDelegate.m
#import "TestAppDelegate.h"
#import "MyViewController.h"
@implementation TestAppDelegate
@synthesize window=_window;
@synthesize myViewController=_myViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
self.myViewController = aViewController;
// Or, instead of the line above:
// [self setMyViewController:aViewController];
[aViewController release];
self.window.rootViewController = self.MyViewController;
[self.window makeKeyAndVisible];
return YES;
}
/* Other methods omitted from the listing. */
- (void)dealloc {
[_myViewController release];
[_window release];
[super dealloc];
}
@end
該行:
self.window.rootViewController = self.MyViewController;
有問題
Objective-C區分大小寫。 您寫的是大寫的M而不是小寫的。
self.window.rootViewController = self.myViewController;
您的窗口尚不存在(至少從我在您的代碼中看到的)。 在導致SIGABRT的行之前添加以下代碼:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.