thar
thar

Reputation: 1104

Xcode error: xpected to have a root view controller at the end of application launch

I'am getting this error ( Applications are expected to have a root view controller at the end of application launch ) and i'am not sure why? I was expecting something like the token is: 38c866dd bb323b39 ffa73487 5e157ee5 a85e0b7c e90d56e9 fe145bcc 6c2c594b. But no :(

Really hope someone has a solution for this issue. Thank you, for using you time on this.

The code is as follow.

#import "AppDelegate.h"
#import "ViewController.h"

@implementation AppDelegate

@synthesize window;
@synthesize viewController;

 - (void)applicationDidFinishLaunching:(UIApplication *)application {    

[window addSubview:viewController.view];
//[self.window setRootViewController:viewController];

[window makeKeyAndVisible];

NSLog(@"Registering for push notifications...");    
[[UIApplication sharedApplication] 
 registerForRemoteNotificationTypes:
 (UIRemoteNotificationTypeAlert | 
  UIRemoteNotificationTypeBadge | 
  UIRemoteNotificationTypeSound)];

}

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 

NSString *str = [NSString 
                 stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(str);

}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:     (NSError *)err { 

NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(str);    

}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

for (id key in userInfo) {
    NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
 }    

 }


- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
 }

@end

Upvotes: 0

Views: 824

Answers (1)

rob mayoff
rob mayoff

Reputation: 385500

Your code is out of date. You should not be adding your view controller's view as a subview of your window. You should be setting the rootViewController property of your window to your view controller:

window.rootViewController = viewController;

Upvotes: 1

Related Questions