【发布时间】: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