gpt4 book ai didi

iphone - 程序收到信号“EXC_BAD_ACCESS”

转载 作者:行者123 更新时间:2023-12-01 19:14:47 26 4
gpt4 key购买 nike

当我运行以下代码时,出现上述错误

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

[self.window makeKeyAndVisible];

self.viewController = [[ViewController alloc] initWithNibName:nil bundle:nil];
self.firstViewController=[[FirstViewController alloc]initWithNibName:nil bundle:nil];
UINavigationController *localNavigationController=[[UINavigationController alloc]initWithRootViewController:self.viewController];
self.navigationController=localNavigationController;
[localNavigationController release];
UINavigationController *localFistNavigationController=[[UINavigationController alloc]initWithRootViewController:self.firstViewController];
self.firstNavigationController=localFistNavigationController;
[localNavigationController release];
NSArray *twoBars=[[NSArray alloc]initWithObjects:self.navigationController,self.firstNavigationController, nil];
UITabBarController *localTAbBarController =[[UITabBarController alloc]init];
[localTAbBarController setViewControllers:twoBars];
self.tabBarController=localTAbBarController;
[localTAbBarController release];
[self.window addSubview:self.tabBarController.view];

return YES;
}

如果我运行以下代码,它将运行良好
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window makeKeyAndVisible];

self.viewController = [[ViewController alloc] initWithNibName:nil bundle:nil];
self.firstViewController = [[FirstViewController alloc] initWithNibName:nil bundle:nil];

self.navigationController = [[UINavigationController alloc]
initWithRootViewController:self.viewController];

self.firstNavigationController=[[UINavigationController alloc]initWithRootViewController:self.firstViewController];
NSArray *twoBars=[[NSArray alloc]initWithObjects:self.navigationController,self.firstNavigationController, nil];

self.tabBarController=[[UITabBarController alloc]init];
[self.tabBarController setViewControllers:twoBars];

[self.window addSubview:self.tabBarController.view];



return YES;

我不明白这些有什么区别。在第一个中,我刚刚创建了局部变量并将其分配给属性。在后面的一个中直接使用了属性。
为什么给出错误程序收到的信号“EXC_BAD_ACCESS”

最佳答案

我认为在第一个中,您发布了一些代码,然后在发布后再次发布了该对象,例如:
[localTAbBarController release];这个。也许这就是为什么您收到错误程序

信号“EXC_BAD_ACCESS”。在第二个中,您很好地使用了对象而没有发布,因此它的工作

精细。

关于iphone - 程序收到信号“EXC_BAD_ACCESS”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14066053/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com