【发布时间】:2010-11-23 02:46:18
【问题描述】:
我试图在实用程序模板应用程序的反面视图上显示一些数据,但应用程序在 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;
}
非常感谢您的帮助, 非常感谢...
【问题讨论】:
-
MyModelObject中有什么可疑之处? -
您是否已将范围缩小到导致错误的确切行?至少
[dictionary release];行是错误的,应该删除。你没有分配dictionary所以不要释放它。
标签: iphone objective-c ios