Auto remove the observer from NSNotificationCenter after the oberser dealloc, base on TTGDeallocTaskHelper.
iOS 6 and later.
TTGNotificationGuard is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TTGNotificationGuard"
- TTGNotificationGuard is default off, so you must turn it on first.
#import "NSNotificationCenter+TTGNotificationGuard.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Enable the TTGNotificationGuard
[NSNotificationCenter ttg_setTTGNotificationGuardEnable:YES];
return YES;
}
- No more need to do. Just start coding as usual :)
To run the example project, clone the repo, and run pod install
from the Example directory first.
zekunyan, zekunyan@163.com
TTGNotificationGuard is available under the MIT license. See the LICENSE file for more info.