Shu*_*puS 0 memory-management objective-c ios
我有一个方法,不要使用ARC:
-(void)readAppPlist
{
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: %@, formatL %d", errorDesc, format);
}
items = [[temp objectForKey:@"Items"] mutableCopy];
}
Run Code Online (Sandbox Code Playgroud)
根据内存管理规则,我需要为变量plistPath,plistXML,errorDesc,temp释放内存?我应该另外一个方法,在这里发布它们或者只是将它们放入这个类的dealloc全局方法中吗?
假设你正确地遵循命名约定(这可能是一个相当大的飞跃),答案将是:
plistPath:没有
plistXML:没有
errorDesc:没有
temp:没有
规则是如果您alloc copy或retain它,您必须释放它(new计为alloc)
| 归档时间: |
|
| 查看次数: |
247 次 |
| 最近记录: |