Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多次触发事件 #4

Closed
IDOKN opened this issue Aug 13, 2018 · 2 comments
Closed

多次触发事件 #4

IDOKN opened this issue Aug 13, 2018 · 2 comments

Comments

@IDOKN
Copy link

IDOKN commented Aug 13, 2018

if (eventType && isCFNotifiction) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:eventType object:nil];
}

如果是同一个eventType 这里会进来多次 导致多次触发事件

@IDOKN
Copy link
Author

IDOKN commented Aug 13, 2018

NSArray * subscribers = [self.collection objectsForKey:groupId];
if (eventType && isCFNotifiction && 0 == subscribers.count) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:eventType object:nil];
}

改成这样?

@LeoMobileDeveloper
Copy link
Owner

LeoMobileDeveloper commented Aug 13, 2018

多谢反馈,你建议的方式会有线程安全的问题,我在这个commit中修复了多次回调的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants