Alex Rivera | Logout

Multiple Delegates in Objective C

Asked 2009-09-05T02:08:34.597
39

I'm coming from the C# event model, and I'm wondering if there is a standard way to notify multiple delegates of an event?

I have a ClassCDelegate protocol that I want both ClassA and ClassB to implement. Is there a way I can assign an instance of ClassC both ClassA and ClassB as delegates without having to manually create a list of delegate variables within ClassC and iterate through them?

Edit
Report

2 Answers

3

It's also important to note that Notifications are a one-way street - They cannot send information back, as delegates can. The only case where you'd want to iterate through a list of delegates is if your delegating class expects back information from its delegates.

answered 2010-02-12T23:17:45.797
2

You can only have one delegate object. If you want to notify various objects of changes you should use the NSNotificationCenter and post NSNotification messages that your objects can listen for.

answered 2009-09-05T02:14:07.757

Your Answer