简体   繁体   English

从观察者中删除特定选择器

[英]Remove a specific selector from observer

Hi I have a problem with notificationCenter. 嗨我有一个notificationCenter问题。 I'm launching the load of three different feeds and I'm registering three notifications with three different selector (the observer object is the same for the three notifications). 我正在启动三个不同的feed的加载,我正在使用三个不同的选择器注册三个通知(三个通知的观察者对象是相同的)。

notification1 -> selector1 notification1 - > selector1

notification2 -> selector2 notification2 - > selector2

notification3 -> selector3 notification3 - > selector3

All works fine but I can't unregister the observer when I receive the feed content because in that case i'm blocking to receive the other two feeds. 一切正常,但是当我收到提要内容时我无法取消注册观察者,因为在这种情况下我阻止接收其他两个提要。 otherwise if I don't unregister the observer I'm getting the notification twice if I resend the same query with the same selector and notification name. 否则,如果我不注销观察者,如果我使用相同的选择器和通知名称重新发送相同的查询,我将收到两次通知。

Are there any way to unregister just the selector without unregister the object? 有没有办法只注销选择器而不注销对象?

- (void)removeObserver:(id)notificationObserver name:(NSString *)notificationName object:(id)notificationSender

is the method you're looking for. 是你正在寻找的方法。 Just pass the correct notificationName for each case. 只需为每个案例传递正确的notificationName。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM