iOS: NSNotificationCenter的方法addObserverForName:object:queue:usingBlock:

来源:互联网 发布:pc客户端制作软件 编辑:程序博客网 时间:2024/05/12 11:13

- (id)addObserverForName:(NSString *)name object:(id)obj queue:(NSOperationQueue *)queue usingBlock:(void (^)(NSNotification *))block





NSNotificationCenter *center = [NSNotificationCenter defaultCenter];


NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];


self.localeChangeObserver = [center addObserverForName:NSCurrentLocaleDidChangeNotification object:nil


    queue:mainQueue usingBlock:^(NSNotification *note) {


 


        NSLog(@"The user's locale changed to: %@", [[NSLocale currentLocale] localeIdentifier]);


    }];


NSNotificationCenter *center = [NSNotificationCenter defaultCenter];


[center removeObserver:self.localeChangeObserver];



原创粉丝点击