I'm using ARC. Will ARC automatically release all the properties in dealloc
? Is it necessary to manual set all public properties and private field to nil
? Are there any good pattern to follow?
2 回答
Under ARC, the pattern is... don't do anything in dealloc, or even implement it. ARC takes care of your properties and instance variables for you.
The only exception is that dealloc is a good place to unregister for notifications, if your object has registered for any.
Good question. When using ARC
the compiler will implement a dealloc
method for you and will handle implicitly the release of your instance variables and properties.
You may still need a custom -dealloc
if your class needs to do anything other than releasing memory (e.g unregister for notifications like jrturton mentioned).
You can get a good grasp of what's you need to consider when transitioning to ARC in those Apple official notes.