当我运行以下代码时,它给出了上述错误
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window makeKeyAndVisible];
self.viewController = [[ViewController alloc] initWithNibName:nil bundle:nil];
self.firstViewController=[[FirstViewController alloc]initWithNibName:nil bundle:nil];
UINavigationController *localNavigationController=[[UINavigationController alloc]initWithRootViewController:self.viewController];
self.navigationController=localNavigationController;
[localNavigationController release];
UINavigationController *localFistNavigationController=[[UINavigationController alloc]initWithRootViewController:self.firstViewController];
self.firstNavigationController=localFistNavigationController;
[localNavigationController release];
NSArray *twoBars=[[NSArray alloc]initWithObjects:self.navigationController,self.firstNavigationController, nil];
UITabBarController *localTAbBarController =[[UITabBarController alloc]init];
[localTAbBarController setViewControllers:twoBars];
self.tabBarController=localTAbBarController;
[localTAbBarController release];
[self.window addSubview:self.tabBarController.view];
return YES;
}
如果我运行以下代码,它运行良好
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window makeKeyAndVisible];
self.viewController = [[ViewController alloc] initWithNibName:nil bundle:nil];
self.firstViewController = [[FirstViewController alloc] initWithNibName:nil bundle:nil];
self.navigationController = [[UINavigationController alloc]
initWithRootViewController:self.viewController];
self.firstNavigationController=[[UINavigationController alloc]initWithRootViewController:self.firstViewController];
NSArray *twoBars=[[NSArray alloc]initWithObjects:self.navigationController,self.firstNavigationController, nil];
self.tabBarController=[[UITabBarController alloc]init];
[self.tabBarController setViewControllers:twoBars];
[self.window addSubview:self.tabBarController.view];
return YES;
我不明白这些之间有什么区别。在第一个中,我刚刚创建了局部变量并将其分配给属性。在后面的一个中直接使用了属性。为什么它给出错误程序接收信号“EXC_BAD_ACCESS”