2010-09-02 94 views
1

這個方法在我的類中讀取一個先前創建的plist,但是當它發生NSPropertyListSerialization泄漏到處都是。主要是NSDates和NSCFStrings。關於我能做些什麼來防止這種情況的任何建議?使用NSPropertyListSerialization時發生內存泄漏

- (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; 
} 

回答

相關問題