0
我有没有ARC的方法来读取plist文件内容:自动释放造成系统崩溃的iOS
-(void)readAppFile
{
NSString *plistPath = [self getDataFileDestinationPath];
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSMutableDictionary *temp = (NSMutableDictionary *) [NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
if (!temp) {
NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
}
items = [[temp objectForKey:@"Items"] mutableCopy];
NSLog(@"Read file!");
}
我在这里有一个伟大的内存泄漏!所以我用这行items = [[[temp objectForKey:@"Items"] mutableCopy] autorelease];
代替代码的结尾,但现在我有Thread 1: EXC_BAD_ACCESS (code=1, addres=0x6000000008)
。今天是第二天,我不知道如何处理这种方法。
MEM泄漏,但在哪里? plistPath,plistXML,格式,温度,项目......哪一个? – 2013-04-09 18:36:00
release'items',而不是整个'objectForKey:'东西 – CodaFi 2013-04-09 18:36:23
@AnoopVaidya项目 - 这是我必须发布的唯一一个对象。但我不明白 - autorelease有什么问题.. – ShurupuS 2013-04-09 18:44:26