Auto remove KVO observer from object after the object or the observer dealloc, base on TTGDeallocTaskHelper.
iOS 6 and later.
TTGKVOGuard is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TTGKVOGuard"
- TTGKVOGuard is default off, so you must turn it on first.
#import <TTGKVOGuard/NSObject+TTGKVOGuard.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Enable the TTGKVOGuard
[NSObject ttg_setTTGKVOGuardEnable: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
TTGKVOGuard is available under the MIT license. See the LICENSE file for more info.