I am using the NSXMLParser and would like to release some of the objects as soon as I am done with them in the parsing. However, I am not sure if that would mess up the automatic reference counting in IOS5 ? Is that a bad practice to release the objects asap in the code in IOS5 when you are done with them?
Share
Few things, one of them should be your answer:
in an ARC project you can’t call retain or release. A call to those methods will produce a compile time error, so you really cannot do any manual memory management any more.
on the other hand you can turn ARC on and off on a per file basis. That’s very easy to do- open the project settings, click on “build phases”, open the “compile sources” strip, then select the desired .m file and hit “enter” on the keyboard – in the popup window enter “-fno-objc-arc”. Close and re-start Xcode (they still have a bug with this, so … ). Now ARC is disabled for this file – you can use retain and release in the code and everything
however there’s also another way to go – use a release pool. In general if you are about to consume lot of memory and you wanted it released faster you should use a separate memory pool, it’s very easy to do that and the new iOS5 way looks like this:
So, all the allocations happening between the curly brackets will be released when you get out of the block – there you go 🙂