How do I assign a delegate to multiple classes
I have a custom delegate, and I want 2 classes to respond to it's events. How can I assign it to both classes.
ie:
viewController.开发者_JS百科delegate = firstClass && self;
You could create a third class that handles the event by delegating it to the two classes.
viewController.delegate = delegatingClass;
...and in the object referred to as delegatingClass, implement the method that you're concerned about by calling that same method on the two classes you want to handle the event. For example:
void handleEvent( Event event ) {
firstClass.handleEvent( event );
otherClass.handleEvent( event );
}
If you need an event to be called multiple places you should use NSNotificationCenter.
加载中,请稍侯......
精彩评论