Some times you won’t want to hard-code the connection between two objects. For example, let’s say we want all the objects to respond to a tap on the canvas. If our objects were created statically we could add them all to the tap’s action block like so:
If the objects were all created dynamically we could keep an array and iterate through it.
Better, but this might not be ideal for your situation either.
Our other option is to use a nice technique that allows the canvas to broadcast an event:
And, when you create your objects, you can do this:
This is an nice alternative that decouples objects. It can be very handy when working between classes and view controllers.
Did you see how you can specify the sender that you want your object to listen to?