Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2014 02:35
Show Gist options
  • Save anonymous/9284141 to your computer and use it in GitHub Desktop.
Save anonymous/9284141 to your computer and use it in GitHub Desktop.
Halps
//Instead of passing in the sender, can I use the Objective-C runtime to figure out the method caller?
+ (instancetype)callsomeMethodWithSender:(id)sender
{
//Prevent this method from being called from outside of this class
if ([self class] == [MyClass class] || [[sender class] isSubclassOfClass:[MyClass class]])
{
//doSomething
}
else
{
NSAssert(NO, @"You cannot call this method from outside of this class.");
return nil;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment