I have a hard time grasping this memory leak in my code. Basically it's returning an object containing a object. here's the following code:
-(id) getOptions {
FileManager *file = [[FileManager alloc] initWithFileName:@"optionsFile.dat"];
Options *options = [[Options alloc] init];
NSMutableArray *fileArray = [[NSMutableArray alloc] init];
fileArray = [file loadFile: @"optionsFile"];
if ([fileArray count] > 0) {
options = [fileArray objectAtIndex:0];
}
[file release];
return options;
}
I try to retain the returned object and releasing right after using:
id options = [[self getOptions] retain];
[options release];
Basically, from the iphone documentation, i should have it autoreleased on my mutatbe array for filearray, but i am still getting a memory leak, anyone can shed some light on this, would be greatly appreciated.
EDIT:
I just added this to see if it would solve anything, but i am still leaking:
FileManager *file = [[FileManager alloc] initWithFileName:@"optionsFile.dat"];
NSMutableArray *fileArray = [file loadFile: @"optionsFile"];
Options *options = [fileArray objectAtIndex:0];
[file release];
return options;