10

Here’s a library submitted by CHEN Xian’an that provides another solution for automatically removing the observer for NotificationCenter without minimal code and without using method swizzling called CXAAutoRemovalNotification.

Here’s a a code example using CXAAutoRemovalNotification from the readme:

__weak typeof(self) weakSelf = self;
[self cxa_addObserverForName:UIContentSizeCategoryDidChangeNotification usingBlock:^(NSNotification *note) {
    [weakSelf.tableView reloadData];
}];

You can find CXAAutoRemovalNotification on Github.