尝试从我的代码中删除内存泄漏时遇到了一些麻烦。在下面的代码中,我在“configurationArray = [[NSArray arrayWithContentsOfFile:controllerConfigurationFilePath] retain];”这一行得到了内存泄漏 但是,当我删除保留时,应用程序崩溃并将保留更改为自动释放也会导致崩溃。
谢谢,威廉
-(NSArray*)decodeConfigurationFile:(NSString*)fileName{
NSArray* configurationArray = [[NSArray alloc] init];
NSString *controllerConfigurationFilePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];
if (controllerConfigurationFilePath != nil) {
// returns array of items storing the data for form
configurationArray = [[NSArray arrayWithContentsOfFile:controllerConfigurationFilePath] retain];
}
// returns fields dictionary objects from plist into an array
return [[configurationArray objectAtIndex:0] objectForKey:@"fields"];
}