views:

28

answers:

2

i'm working on app for iphone on objective-c i have array with object references If i remove item with object reference from array should i release this object additionally or it will be removed from memory automatically?

+2  A: 

When removed from array object gets released once. So if your retain/release are paired correctly in other places you must not release your object in this case.

Vladimir
A: 

If the NSArray (um, it is an NSArray, isn't it? C arrays provide no ownership management) is the only thing that owns the object -- that is, if the object added was acquired autorelease-d or you explicitly called release after adding -- then it will be cleaned up automatically on removal. Any other ownership claims will still need to be release-d as normal.

walkytalky