Memory leak by pragmatically updating bound NSMutableArray?
Memory leak by pragmatically updating bound NSMutableArray?
- Subject: Memory leak by pragmatically updating bound NSMutableArray?
- From: John Morgan <email@hidden>
- Date: Tue, 22 Mar 2005 18:27:14 -0800
Hello,
In my custom Controller class I have a NSMutableArray of NSDictionaries
that is being populated by a NSURLRequest to a PHP script which is
called by an NSTimer. I have an NSObjectController that has it's
content outlet linked to my custom Controller class. I also have an
NSArrayController that has it's contentArray bound to the
NSObjectController key representing the NSMutablyArray. I then have a
NSTableView that has it's columns bound to the keys in the
NSArrayController.
This all updates properly as far as I can tell. Each time the timer
fires the table view is updated correctly (though it does reset the
view to the top again which I haven't looked at yet). The only thing is
when I run MallocDebug it reports a leak that contains some NSStrings
that are in the NSDictionary. It appears to be 1 NSString for each time
the timer fires.
I have gone back through the code multiple times and any alloc/init I
have I release when done. Only thing I can think of is that I have
created the KVC setters/getters for the NSMutableArray that is being
observed by the NSObjectController and update the whole array all at
one time using the setter with a new array. Is this the proper way of
doing it? Could this be where my leak is?
My setter for the array is as follows (not sure if it will help any):
-(void)setMyArray:(NSArray)myNewArray
{
[myArray autorelease];
myArray = [myNewArray mutableCopy];
}
Any help would be greatly appreciated.
- JD
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden