As others mentioned in their answers, there are two mainstream ways we do this.There is sufficient literature on the internet about the usage of both. I will provide short explanations in my own words
Delegates
Delegation refers to the process of passing on a piece of work to some other object which is better suited to perform that task. You can go the delegate way given you have with you both the delegate and delegating object.
In your case, the viewController with the collection view will be the delegating object where as the view controller that sets the image will be the delegate.
Basically you will need the following in the delegating viewcontroller.
A 'protocol' which will include a method to pass the required
information to the delegate object.
A delegate object.
A reference to the second view controller, which will be set as the
delegate of the first viewcontroller.
Call the method on the delegate wherever applicable.
In the delegate view controller
- You will have to confirm to the protocol declared earlier.
- Implement the required methods in the protocol.
Notifications
Notifications are more like broadcasts. You send out an app wide message that can be received and processed by any listeners. We use the NSNotification class for this. The information or the message will be captured in the NSNotification's userInfo object. Each notification is identified by a name.
The advantage of notifications is that you do not typically need to keep track or references of listeners. You just need to generate the payload data, publish a notification and be done with it. The notification can be listened to by any class and your information has the potential to be processed in any object that is alive give it is listening for it. This can become an advantage or a disadvantage.
Comparison
In my personal experience, working in large projects excessive use of Notifications combined with repeated unplanned patching in of changes and fixes eventually leads to unreadable & unmaintainable code. Delegation requires more planning and time to implement, but you always know who's doing what. That said these are two different tools and should be used as per the requirement.