iphone - Help with Memory leak: init NSMutableArray from file -


At some point in my app, I need to load a list from a file, so I used to load the list I apply this method: - (zero) load list {NSString * filePath = [self-data-file path]; // This is the way to return a method file if ([[NSFileManager defaultManager] fileExistsAtPath: filepath] {NSMutableArray * tempArray = [[NSMutableArray alloc] initWithContentsOfFile: filepath]; Self.list = [[NSMutableArray alloc] initWithArray: tempArray]; [TempArray release]; }}

self.list is a (retaining) property.

I think the leak is from [alloc] when I init in selfl.list. I used

  self.list = [[NSMutableArray alloc] initWithArray: tempArray] autorelease];   

But the app crashes due to EXC_BAD_ACCESS so I'm confused here how to solve it.

Thanks for any suggestions.

"itemprop =" text ">

simply assign,

  self.list = tempArray; As   

tempArray is already an array, you do not need to create another array from it. You can specify self.list directly

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -