NSMutableArray and releases etc
NSMutableArray and releases etc
- Subject: NSMutableArray and releases etc
- From: Alan leigh <email@hidden>
- Date: Fri, 11 Oct 2002 02:03:07 +1000
Hi all... I have code which does some fairly lengthy iterations... so
naturally I cop any memory leaks pretty hard. I'm trying to figure out
where I'm leaking some.. and here is my question (I know, I know I
should re-write my code to use a C, or real man (or woman's) array, but
right now I'm still testing a few things before I go for speed).
Anyway, the question.. so I have this...
NSMutableArray* ratings;
[ratings addObject:[NSNumber numberWithFloat:[self
someFnWhichReturnsFlt]]];
So as i understand it... I can assume the NSNumber is autoreleased but
gets a +1 retain from the addObject. If I'm careful to not just release
ratings, but also 'removeAllObjects' I guess that's ok.. but what if
ratings just dies as a result of its auto release (assuming it too is
temporary)?? Is this just bad coding or can I account for it? Or does
Array send a release to all it's objects as it dies (which would be
consistent with addObject: and removeObject: I guess... but i can't
find any documentation of it...
Cheers,
Alan (staring at a 'top' screen) :)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.