id observer = [[NSNotificationCenter defaultCenter] addObserverForName:@"XXX" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
NSLog(@"doing...");
}];
// 销毁方法如下:
[[NSNotificationCenter defaultCenter] removeObserver:observer];
网友评论