この次のコードを実行すると、上記のエラーが発生します
- (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」が発生する理由