Skip to content

Instantly share code, notes, and snippets.

@pitiphong-p
Created February 7, 2019 05:03
Show Gist options
  • Save pitiphong-p/b717a94511af726d224ab31a278fb0d3 to your computer and use it in GitHub Desktop.
Save pitiphong-p/b717a94511af726d224ab31a278fb0d3 to your computer and use it in GitHub Desktop.
Creating a KeyPath from Selectors
inline NSString * PTPKeyPathForSelectors(SEL selector, ...) {
if (!selector) {
return nil;
}
NSMutableArray *selectors = [NSMutableArray array];
va_list args;
va_start(args, selector);
SEL arg = selector;
do {
[selectors addObject:NSStringFromSelector(arg)];
} while((arg = va_arg(args, SEL)));
va_end(args);
return [selectors componentsJoinedByString:@"."];
}
@pitiphong-p
Copy link
Author

An archive of my NSHipster Reader Submissions of 2014
https://nshipster.com/new-years-2014/#creating-a-keypath-from-selectors

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