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: self.list is a (retaining) property. I think the leak is from [alloc] when I init in selfl.list. I used But the app crashes due to EXC_BAD_ACCESS so I'm confused here how to solve it. Thanks for any suggestions. simply assign, tempArray is already an array, you do not need to create another array from it. You can specify self.list directly - (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 = [[NSMutableArray alloc] initWithArray: tempArray] autorelease];
self.list = tempArray; As
Comments
Post a Comment