- (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSNotificationName)aName object:(nullable id)anObject;
我们看看Apple对这个方法的解释:
Adds an entry to the receiver’s dispatch table with an observer, a notification selector and optional criteria: notification name and sender.
If your app targets iOS 9.0 and later or macOS 10.11 and later, you don't need to unregister an observer in its deallocation method. If your app targets earlier releases, be sure to invoke removeObserver:name:object: before observer or any object specified in addObserver:selector:name:object: is deallocated.
Apple说明这个方法会把“an observer, a notification selector and optional criteria: notification name and sender.”作为参数,给receiver的调度列表添加一个入口。如果app的目标用户是iOS 9.0 and later or macOS 10.11及之后,我们不需要在dealloc方法中取消注册者观察者,如果你的APP目标用户要稍早一些,要确保观察者在dealloc前调用remove方法。
结论:目前大家最低支持的是iOS8,因此还是需要移除的。等明年就不需要了,因为明年就可以不支持iOS8了,直接支持iOS9了。