我班级中的这个方法读取以前创建的plist,但是当它确实存在时,NSPropertyListSerialization会在整个地方泄漏。 NSDates和NSCFStrings,主要是。关于我可以做些什么来防止这种情况的任何建议?
- (id)readPlist:(NSString *)fileName {
NSData *plistData;
NSString *errorA;
NSPropertyListFormat format;
id plist;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *localizedPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:fileName];
plistData = [NSData dataWithContentsOfFile:localizedPath];
plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&errorA];
if (!plist) {
DLog(@"Error reading plist from file '%s', error = '%s'", [localizedPath UTF8String], [errorA UTF8String]);
[errorA release];
}
return plist;
}