Question

I init my NSXMLParser with a mutable data, that I get from the internet. I wonder whether the parser releases it on its deallocation or I have to release it after the parsing?

Thanks

Was it helpful?

Solution

Cocoa uses the "It's not my problem" metaphor to memory management.

If you pass something to another object, it is that objects responsibility to retain it.

If something is passed to one of your objects, you need to retain it or it may go away.

Generally pass objects like:

    [otherObject doSomethingWith:[myThing autorelease]];

OR

    [otherObject doSomethingWith:myThing];
    [myThing release];

The Cocoa frameworks work on this principle and you should design your classes the same way.

OTHER TIPS

If you have retained it, and you no longer use it, then release it. The NSXMLParser will most likely retain the data itself and release it when it is finished with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top