相关疑难解决方法(0)

如何通过Objective-C中的NSNotificationCenter创建一个发送和接收事件的类?

我需要创建两个类,两者都应该能够通过NSNotificationCenter方法发送和接收事件.两者都应该有sendEvent和receiveEvent方法:

      @implementation Class A
-(void)sendEvent
{
    addObserver:---  name:---- object:---
}

-(void)ReceiveEvent
{
postNotificationName: --- object:---
}
@end
Run Code Online (Sandbox Code Playgroud)

与另一个类相同,ClassB也应该能够发送和接收事件.怎么做到呢?

objective-c nsnotification nsnotificationcenter

5
推荐指数
1
解决办法
1万
查看次数