Skip to content

Instantly share code, notes, and snippets.

@danwood
Created May 30, 2014 22:52
Show Gist options
  • Save danwood/edda9cb37b1fc57bb13a to your computer and use it in GitHub Desktop.
Save danwood/edda9cb37b1fc57bb13a to your computer and use it in GitHub Desktop.
- (void)ks_tryToMakeObjectsPerformSelector:(SEL)selector withObject:(id)object;
{
for (id <NSObject> anObject in self)
{
if ([anObject respondsToSelector:selector])
{
[anObject performSelector:selector withObject:object];
}
}
}
@mbabin
Copy link

mbabin commented May 31, 2014

- (void)ks_tryToMakeObjectsPerformSelector:(SEL)selector withObject:(id)object;
{
    for (id <NSObject> anObject in self)
    {
        if ([anObject respondsToSelector:selector])
        {
            IMP imp = [anObject methodForSelector:selector];
            void (*func)(id, SEL, id) = (void *)imp;
            func(anObject, selector, object);
        }
    }
}

StackOverflow reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment