以下代码使用了arc后,切换视图的时候会报错:progran received signal:"exc_bad_access"关闭arc后,正常切换,请问这是什么问题,哪里错误了?  请指点迷津,谢谢- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    
    //生成各个视图控制器
    a* aa = [[a alloc]init];
    b* bb = [[b alloc]init];
    c* cc = [[c alloc]init];
    d* dd = [[d alloc]init];
    e* ee = [[e alloc]init];
    //加入一个数组    
    NSArray* controllerArray = [[NSArray alloc]initWithObjects:aa,bb,cc,dd,ee ,nil];
    //创建UITabBarController控制器  
    UITabBarController* tabBarController = [[UITabBarController alloc]init];
    //    设置委托
    tabBarController.delegate = self;
    //设置UITabBarController控制器的viewControllers属性为我们之前生成的数组controllerArray
    tabBarController.viewControllers = controllerArray;
    //默认选择第1个视图选项卡(索引从0开始的)
    tabBarController.selectedIndex = 0;
    //读取
    UIViewController* activeController = tabBarController.selectedViewController;
    if(activeController == aa){
        //
    }
    //    把tabBarController的view作为子视图添加到window
    [self.window addSubview:tabBarController.view];
    
    //定制按钮
    /*NSMutableArray* customzableViewControllers = [[NSMutableArray alloc]init];
     [customzableViewControllers addObject:musicList];
     [customzableViewControllers addObject:currentPlay];
     [customzableViewControllers addObject:favourite];
     tabBarController.customizableViewControllers = customzableViewControllers;
     
     tabBarController.customizableViewControllers = nil;
     */
    //
//    [musicList release];
//    [currentPlay release];
//    [favourite release];
//    [singerList release];
//    [settings release];
    
    [self.window makeKeyAndVisible];
    return YES;
}

解决方案 »

  1.   

    arc?请解释一下。这个错误是release早了某对象造成的。看了几个帖子,忍不住普及一下:release和autorelease自己管理时release----对象的创建销毁完全能自我控制。
    自己管不了autorelease-----对象只能被创建,销毁不受控制。至于为什么,在此不赘述,查阅相关资料。
      

  2.   

    exc_bad_access楼上正解你看看哪里的内存有问题还有,建议使用 UITabbarController等问题使用XIB链接好些。
      

  3.   

    那天找到问题了,arc将UITabBarController提前release掉了,只要定义在h文件中就解决了,哈哈,谢谢2位