[xcode]程序中意外的'@'

时间:2013-01-21 16:43:24

标签: xcode

我有这样的代码

Initialize List View Controller
MTListViewController *listViewController = [[MTListViewController alloc] init];
// Initialize Navigation Controller
UINavigationController *listNavigationController = [[UINavigationController alloc]        initWithRootViewController:listViewController];
// Initialize Tab Bar Controller
UITabBarController *tabBarController = [[UITabBarController alloc] init];
// Configure Tab Bar Controller
[tabBarController setViewControllers:@[listNavigationController]];

我在最后一行收到错误“意外'@'在程序中”。怎么回事?我的xcode版本是4.2

1 个答案:

答案 0 :(得分:2)

  

我的xcode ersion是4.2

直到Xcode 4.4才支持新的数组文字。您需要使用等效的旧语法:

[tabBarController setViewControllers:[NSArray arrayWithObject:listNavigationController]];