【问题标题】:debug error EXC_BAD_ACCESS in main.mmain.m 中的调试错误 EXC_BAD_ACCESS
【发布时间】:2012-04-08 17:35:53
【问题描述】:

酒吧控制器, 我的项目名称是“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;
}

有没有人遇到或知道上述错误? 谢谢!

【问题讨论】:

  • 使用 ARC 并删除 autorelease
  • dealloc 方法是什么样的?
  • 抱歉,请问什么是ARC?你的意思是我需要删除所有 [...autorelease] 代码?或者要删除哪个自动释放?

标签: xcode xcode4 ios4 uitabbarcontroller xcode4.2


【解决方案1】:

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

【讨论】:

  • 我是否也应该在 2 个视图的 2 个 .m 文件中使用 dealloc 方法?目前我在 AppDelegate.m 文件中只有 dealloc 方法
猜你喜欢
  • 2011-09-15
  • 2013-11-17
  • 2013-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-16
  • 2012-09-25
  • 1970-01-01
相关资源
最近更新 更多