简体   繁体   中英

Expected getter method not found, Xcode iOS

I am using Apple's newest Xcode for MacOS 10.7(Lion). I am trying to make a iPhone application. I'm new to the language and decided to load up apples guides. 'Your first iOS application'. It was good, taught me a few things but Its not working. I get Expected Getter Method Not Found On Object Of Type 'TestAppDelegate *'

How do i Fix this?

Heres the code:

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

The line:

self.window.rootViewController = self.MyViewController;

Has the problem

objective-c is case-sensitive. You wrote an upper-case M instead of lower-case.

self.window.rootViewController = self.myViewController;

Your window doesn't exist yet (at least from what I can see in your code). Add this before the line causing the SIGABRT:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM