Latest 1.0.0
License MIT
Platforms ios 6.0, requires ARC

allow people to multicast the delegate methods invocation to multi delegate objects.

updated for mixing with swift. see demo for more detail.


it uses some runtime methods such as respondsToSelector:, methodSignatureForSelector: and forwardInvocation: to achieve the method invocation cast.

you can set some object’s delegate property like this:

XLYMultiCastDelegate *multiCastDelegate = [[XLYMultiCastDelegate alloc]initWithConformingProtocol:@protocol(AProtocol)];
[multiCastDelegate addDelegate:firstDelegate dispatchQueue:firstDispatchQueue];
[multiCastDelegate addDelegate:secondDelegate dispatchQueue:secondDispatchQueue];
object.delegate = (id<AProtocol>)multiCastDelegate;

then when the object call a delegate method for example ‘hello’, the multiCastDelegate can forward the invocation to firstDelegate and then to secondDelegate. firstDelegate will receive ‘hello’ in firstDispatchQueue and secondDelegate will receive in secondDispatchQueue.

this is different with normal delegate. Normal delegate can only be a single object who confirms to ‘AProtocol’, while using MultiCastDelegate, all the interesting objects can receive a method calling.

It is also different with Notification. Notification ask for a string to be the Notification name and a selector to be called when Notification post. Developers should also remove observer at appropriate time. MultiCastDelegate require all the delegates added to confirm a certain protocol, or else the add action will fail at rumtime. It use method call rather than a string and a selector which is hard to maintain to achieve multi notification.

Latest podspec

    "name": "XLYMultiCastDelegate",
    "version": "1.0.0",
    "summary": "use delegate instead of NSNotification to cast message to mulitiple objects.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "kaizei": "[email protected]"
    "platforms": {
        "ios": "6.0"
    "source": {
        "git": "",
        "tag": "v1.0.0"
    "source_files": "codes/**/*.{h,m}",
    "requires_arc": true

Pin It on Pinterest

Share This