I have an NSMutableArray of objects (in my case some systems). I’m requesting new data for the systems by reading XML’s and from them I’m creating some new systems. In some cases I want to update the systems in my NSMutableArray, sometimes not..
Therefore, when I want an update I say
system = [updatedSystem copy];
(My system model has implemented - (id)copyWithZone: (NSZone *) zone)
My question is, do I need to release my old system object prior to system = [updatedSystem copy];?
I.e.
[system release];
system = [updatedSystem copy];
Yes if copied it, you have to
release, cause the copied object isn’t released before being returned from the copy function.