Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialrickkettner
8,061 PointsHow do we assign multiple delegates?
The problem outlined in this video series was that a Race might need to be monitored by both a Tracker AND a RaceBroadcaster (perhaps with even a few more objects listening as well), but it appears that we can only assign a single delegate at a time, so while this decouples the code - it doesn't actually solve the problem of having the events sent to multiple objects.
Is there a way to assign multiple delegates?
3 Answers
Franklin Byaruhanga
9,984 PointsThe delegate protocol pattern is used for a one to one communication, not a one to many. If you want a one to many communication you should use the Observer & Notification Pattern. I got a better explanation from the youtube videoβs below:
rickkettner
8,061 PointsThank you for your help Franklin!
Michael lara
8,208 Pointsrickketter asked a very good question, because the same question came to my mind... And Franklin provided a very good explanation.. Thanks both of you