Does NSMutableArray -removeLastObject create a RELEASE object?

I'm talking about methods like -removeAllObjects, -removeLastObject, etc. for NSMutableArray. The documentation only says that these methods "remove" the object from the array. Have deleted objects been released?

+2


source to share


2 answers


Yes Yes. Any remove triggers the release of the remote NSObject

.

The link NSArray

indicates:



Arrays maintain strong references to their contents - in the managed memory environment, each object receives a save message before adding its id to the array and release message when it is removed from the array or when the array is freed. if you want a collection with different object property semantics, consider using a CFArray, NSPointerArray, or NSHashTable reference instead.

+6


source


Yes, they are released. You can see that the contained object is freed by overriding release

in the object you placed in the container. Call the superclass method release

and set a breakpoint on it. You will see that it has been released.



I initially stated that I thought the objects were automatically released. It turns out that I believe I am wrong.

+2


source







All Articles