ReactiveCocoa / ReactiveObjC

The 2.x ReactiveCocoa Objective-C API: Streams of values over time
MIT License
2.6k stars 496 forks source link

In "- (RACSignal<NSNotification *> *)rac_addObserverForName:(nullable NSString *)notificationName object:(nullable id)object;",if the object is not nil, the notification's block will not be called. #136

Closed XTShow closed 6 years ago

XTShow commented 6 years ago

First of all, thank you very much for providing us with such a great framework! When I use the "- (RACSignal<NSNotification > )rac_addObserverForName:(nullable NSString *)notificationName object:(nullable id)object;", for example:

[[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil] takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(NSNotification * _Nullable x) {
        NSLog(@"%@",x);
    }];

the "object" must be nil, when the app enter background, the block will be called。 But when the object not nil,like @"asd" ,self, the block will not be called. Is the way I use it wrong?

mdiep commented 6 years ago

I'd suggest looking at the documentation for the NSNotificationCenter method. It seems like you might be a little confused about the role of the object parameter.

XTShow commented 6 years ago

@mdiep emmmm....Yes, I confused this object and the context in KVO....This is my fault. Thank you very much!