ios - ARC下在dealloc中将对象置空,这个做法必要吗?
PHP中文网
PHP中文网 2017-04-18 09:18:06
0
2
312

ARC下在dealloc中将对象置空,这个做法必要吗?重写dealloc,并且将类的property置未空,这个做法有用吗?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
左手右手慢动作

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

阿神

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template