问题
I am changing rootViewController of window dynamically in my application in Non - ARC application.
My question is do i need to release previously assigned rootViewController? How memory is management is done with previously allocated rootViewController?
My Second question is about newrootViewController. how i can manage memory for new rootViewController for window.
Any help will be appreciated....
回答1:
Jason is right in his comment above, in reality there are very few reasons not to use ARC. Automatic reference counting is just as efficient if not more so than manual reference counting.
Remember it's not garbage collection, the retain and release statements are simply added at compile time.
To answer your question, if you called alloc / new or copy on the rootViewController then yes you must release the previously allocated controller.
Remember being a memory management snob is not a sufficient reason to not use ARC! ;)
With regard to the newRootViewController object, as soon as you make it the windows 'root view controller' the window retains it, so you can then release it.
Take a look at this question also: Retaining rootViewController?
来源:https://stackoverflow.com/questions/23101595/memory-management-with-changing-rootviewcontroller-of-window