在main.m中调试错误EXC_BAD_ACCESS

时间:2012-03-24 11:36:55

标签: xcode xcode4 ios4 uitabbarcontroller xcode4.2

棒控制器, 我的项目名称是“DebtDevV1”,它在视图“AddDebtor”和“Debtor”之间切换。我是基于“基于选项卡的应用程序”构建的。

当我按下“DebtorViewController”时,它停在main.m下面的编码中 错误讯息:

  

编程收到信号“EXC_BAD_ACCESS”

当我将光标放在DebtDevV1AppDelegate上时,它会显示"Out of Scope"

以下是main.m:

#import "DebtDevV1AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([DebtDevV1AppDelegate class]));
    }
}

以下是DebtDevV1AppDelegate.m

#import "DebtDevV1AppDelegate.h"
#import "AddDebtorViewController.h"
#import "DebtorViewController.h"

@implementation DebtDevV1AppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    UIViewController *viewController1 = [[[AddDebtorViewController alloc] initWithNibName:@"AddDebtorViewController" bundle:nil] autorelease];
    UIViewController *viewController2 = [[[DebtorViewController alloc] initWithNibName:
    @"DebtorViewController" bundle:nil] autorelease];
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}

是否有人遇到过上述错误或有任何想法? 谢谢!

1 个答案:

答案 0 :(得分:0)

这听起来像几个月前的问题。检查你的dealloc方法。确保[super dealloc]是您在dealloc方法中进行的最后一次调用。 EXC_BAD_ACCESS crash when switching back and forth between views