In the MRC era, we need to do a lot of things in dealloc, such as releasing objects, etc.
Now we have entered the arc era, for the release of ordinary objects, the system has helped us do;
Is there any peace of mind? What are we supposed to do under arc?
View:
ARC, the system can help us to release the object, and its contained objects;
However, it is not possible to release something that does not belong to that object, such as:
1. Notice of the viewer
Since the notification center is a single instance of the system, you are actually registered with the Notification center when you register the observer for the notification.
At this point, even if the arc under the system helps us release the object, but the observation in the Notification center is still not removed, then when there is
The notification will still attempt to invoke the method that accepts the notification for that object, which may cause some problems.
It's a bit like, you're off six o'clock at night ... But without a swipe ...
2. Cancellation of a strong delegate/reference to a static object (e.g. Xmppmannerger delegatequeue)
For other objects to treat you as a delegate delegate, and as a strong reference, you are released on your own, but the reference to your object is still there,
You will need to remove the delegate when referencing your object.
3. Do some other things
An object, such as a viewcontroller, may need to deal with the server before it is destroyed;
Then we can also write in the Dealloc
For the underlying implementation of Dealloc, you can refer to the OBJC Runtime code
Examples of what we should do under arc:
-(void) dealloc{ [[nsnotificationcenter defaultcenter] removeobserver:self];//Remove Notification viewer [[Xmppmanager Sharedmanager] removefromdelegatequeue:self];//Remove delegate reference [[MyClass shareinstance] dosomething]//other Actions }
We don't need to do it under arc.
-(void) dealloc{ _name = nil; [_time invalid];}
Summary: The role of Dealloc under ARC is to release resources that the system cannot release, or references to other objects that the object uses.
Source: http://blog.csdn.net/yangbingbinga/
iOS development advanced face Test-arc the role of Dealloc