Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

NickFalk

macrumors 6502
Original poster
Jun 9, 2004
347
1
It's been a while since I've used UIKit to any extent (been enjoying cocos2d for my game stuff). It seemed to flow really easy though when I went back, right up until the moment I decided to make an app that was not set up with a xib-containing template.

Upon running it in the simulator I received the following message: "applications are expected to have a root view controller at the end of application launch."

Which sounds sensible. However what I can't break my head around is why it my subclassed UIViewController won't be accepted as a view controller..

I have a subclassed UIViewController class called MasterController. It has the following init method:

Code:
-(id) init
{
	self	=	[super init];
	if (self) {
		NSLog(@"%@ MasterController init", self);
		[self loadView];
		return self;
	}
	else{
		return nil;
	}
}

I've added the following property to my AppDelegate:
Code:
@property (nonatomic, retain) MasterController *masterController;

It should all come together in the application: didFinishLaunchingWithOptions: method
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	NSLog(@"%@ AppDelegate application", self);
	
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.window.backgroundColor = [UIColor blackColor];	

	self.masterController		= [[[MasterController alloc] init]autorelease];
	self.window.rootViewController	= self.masterController;
			
	[[self window] makeKeyAndVisible];
	return YES;
}

The above mentioned message is returned though.
If I replace my own class with a standard UIViewController the message is not returned so it seems obvious that my subclass is not accepted for some reason...
 
Must be something in the code / settings we're not seeing because I tried the same thing as above in a test project and it worked fine: no "applications are expected..." message.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.