gpt4 book ai didi

iphone - FlipsideViewController 的 viewDidLoad 中的 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-11-29 05:07:28 24 4
gpt4 key购买 nike

我试图在实用程序模板应用程序的反面 View 上显示一些数据,但应用程序在 viewDidLoad 方法结束时中止。我对 iOS 非常陌生,需要一些指导。

[super viewDidLoad];
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"SavedData"ofType:@"plist"];
NSMutableDictionary *tempRootDictionary;
NSMutableArray *tempMutableArray;
if (thePath && (tempRootDictionary = [NSMutableDictionary dictionaryWithContentsOfFile:thePath])) {
NSArray *keys = [tempRootDictionary allKeys];
int keysCount = [keys count];
tempMutableArray = [NSMutableArray arrayWithCapacity:keysCount];
for (int i=0; i<keysCount; i++) {
NSDictionary *dictionary = [tempRootDictionary objectForKey:[keys objectAtIndex:i]];
MyModelObject *aModelObject = [[MyModelObject alloc] init];
[aModelObject setName:[dictionary objectForKey:@"name"]];
[aModelObject setContext:[dictionary objectForKey:@"context"]];
[aModelObject setUsername:[dictionary objectForKey:@"username"]];
[aModelObject setPassword:[dictionary objectForKey:@"password"]];
[tempMutableArray addObject:aModelObject];
[aModelObject release];
[dictionary release];
}
} else {
return;
}

非常感谢您的帮助,非常感谢...

最佳答案

我在发布的代码中看到的唯一明显的问题是:

[dictionary release];

在设置字典的行上,您仅获得对 tempRootDictionary 中对象的引用,而不是它的新分配实例。所以不要释放它。删除该行。

关于iphone - FlipsideViewController 的 viewDidLoad 中的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4252303/

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