有没有人有同样的经历。我有时会收到很多通知。看来我陷入了无限循环。
有什么方法可以过滤和仅收听我希望收听的我自己的设置值吗?
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
[center addObserverForName:NSUserDefaultsDidChangeNotification object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
SettingsManager * s = [SettingsManager sharedSettings];
DLog(@"\n%@ Setting logging: %@", note, s.loggingEnabled ? @"YES" : @"NO");
if (s.loggingEnabled) {
[BPAnalytic startLogging];
} else {
[BPAnalytic stopLogging];
}
}
];