酒吧控制器, 我的项目名称是“DebtDevV1”,它在视图“AddDebtor”和“Debtor”之间切换。我基于“基于标签的应用程序”构建它。main.m中调试错误EXC_BAD_ACCESS
当我按下 “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'。 – 2012-03-25 12:01:37
你的dealloc方法是什么样的? – syclonefx 2012-03-25 13:09:32
对不起,我可以知道什么是ARC?你的意思是我需要删除所有[... autorelease]代码?或哪个autorelease删除? – 2012-03-28 15:06:24