Xcode error: expected identifier

I get the "Expected Identifier" error message in this line of code

UINavigationController *navController1 = [[[UINavigationController alloc] initWithRootViewController:viewController4]]; 

This code is placed in the Delegate application as follows

 #import "AppDelegate.h" #import "FirstViewController.h" #import "SecondViewController.h" #import "ParkTable.h" #import "TableTest.h" @implementation AppDelegate @synthesize window = _window; @synthesize tabBarController = _tabBarController; @synthesize ParkTableDel = _tableViewController; @synthesize navController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; UITableViewController *viewController3 = [[ParkTable alloc] initWithNibName:@"ParkTable" bundle:nil]; UITableViewController *viewController4 = [[TableTest alloc] initWithNibName:@"TableTest" bundle:nil]; UINavigationController *navController1 = [[[UINavigationController alloc] initWithRootViewController:viewController4]]; self.tabBarController = [[UITabBarController alloc] init]; self.ParkTableDel = [[UITableViewController alloc] init]; self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, viewController4, nil]; self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible]; return YES; } // [...] Boilerplate code removed. @end 

I was wondering what I should change to make it right.

+7
source share
3 answers

Could this be an extra set of parentheses? []

+16
source

As Luke noted, you have an extra set of parentheses.

To fix the black screen, try.

 [self.window addSubview: self.tabBarController.view] 

Instead..

 self.window.rootViewController = self.tabBarController; 
+1
source

There was the same problem. This is probably an extra set of [] around your line of code.

0
source

All Articles