Skip to content

Instantly share code, notes, and snippets.

@linjunpop
Created May 31, 2013 07:42
Show Gist options
  • Select an option

  • Save linjunpop/5683456 to your computer and use it in GitHub Desktop.

Select an option

Save linjunpop/5683456 to your computer and use it in GitHub Desktop.
Objective-C dynamic selector
NSString *a = @"bar";
NSString *aSelector = @"uppercaseString";
NSString *b = [a performSelector:NSSelectorFromString(aSelector)];
//NSString *b = objc_msgSend(a, NSSelectorFromString(aSelector));
NSLog(@"b: %@", b);
//=> b: "BAR"
a = "bar"
a_method = "upcase"
a.send(a_method)
# => "BAR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment