Handling multiple delegates in Objective-C is usually done using NSNotificationCenter, but here’s a library from Jacob Jennings that provides an easy to implement alternative with some message handling advantages.
Rather than the usual NSNotificationCenter approach this library uses NSProxy, takes a list of target delegates and implements its own message handling.
As the readme states here is how :
- Messages with a void return type are sent to all target delegates
- Messages with non-void return types are send to the first delegate in the list which responds to the selector.
You can find HTDelegateProxy on Github here with examples of how to use.
A very easy to use library that provides a great alternative to using NSNotificationCenter.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.
The resources we feel will appeal to our readers the most will be posted on the front page.