https://github.com/cxa/cxaautoremovalnotification
[DEPRECATED] Less boilerplate code for NSNotificationCenter.
https://github.com/cxa/cxaautoremovalnotification
Last synced: 4 months ago
JSON representation
[DEPRECATED] Less boilerplate code for NSNotificationCenter.
- Host: GitHub
- URL: https://github.com/cxa/cxaautoremovalnotification
- Owner: cxa
- License: mit
- Created: 2014-12-22T05:34:10.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-01-17T16:38:30.000Z (over 10 years ago)
- Last Synced: 2025-05-04T19:40:01.860Z (about 1 year ago)
- Language: Objective-C
- Homepage:
- Size: 2.93 KB
- Stars: 32
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CXAAutoRemovalNotification
*Notice*: observers of `NSNotificationCenter` are not required to un-register in their deallocation since iOS 9 / OS X 10.11: (https://developer.apple.com/library/prerelease/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11NotificationCenter)
Less boilerplate code for `NSNotificationCenter`.
## Usage
Simply add `NSObject+CXAAutoRemovalNotification.{h|m}` to your project.
Whereever you need `NSNotificationCenter` to observe using block by `- addObserverForName:object:queue:usingBlock:`, just replace it with `-cxa_addObserverForName:object:queue:usingBlock:`, or if don't care `object` and `queue`, use the shorter `- cxa_addObserverForName:usingBlock:` for your notification observer. `CXAAutoRemovalNotification` will take care of the observer removal in deallocation.
### Example
__weak typeof(self) weakSelf = self;
[self cxa_addObserverForName:UIContentSizeCategoryDidChangeNotification usingBlock:^(NSNotification *note) {
[weakSelf.tableView reloadData];
}];
## Creator
* GitHub:
* Twitter: [@_cxa](https://twitter.com/_cxa)
* Apps available in App Store:
## License
Under the MIT license. See the LICENSE file for more information.