我有一个观察者NSNotification被叫两次.我不知道该怎么做.
我用谷歌搜索但没有找到解决方案.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(connectedToServer:) name:@"ConnectedToServer" object:nil];
- (void)connectedToServer:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter] postNotificationName:@"SendMessageToServer" object:message];
}
Run Code Online (Sandbox Code Playgroud) 如果类是自定义类,则在发布通知后,对应于观察者的选择器将被调用两次.是否有更好的解决方案,以便只调用一次选择器?