ARC下在dealloc中将对象置空,这个做法必要吗?重写dealloc,并且将类的property置未空,这个做法有用吗?
ringa_lee2017-04-18 09:20:06
No need, it is MRC that needs to empty (or release) the attributes in dealloc. Automatic reference counting means that the programmer does not need to do it manually. You can do a test, for example, class A has an attribute b that is class B, and then put breakpoints in the dealloc of A and B to see if they are released, unless there are references elsewhere. , or form a circular reference or the like.
It is recommended that you read the memory management part of the document: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html
阿神2017-04-18 09:20:06
In the dealloc method, what you should do is to release references to other objects and cancel the originally subscribed notifications such as KVO or NSNotificationCenter. Do not do anything else