Created
          February 7, 2019 05:03 
        
      - 
      
- 
        Save pitiphong-p/b717a94511af726d224ab31a278fb0d3 to your computer and use it in GitHub Desktop. 
    Creating a KeyPath from Selectors
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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:@"."]; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
An archive of my NSHipster Reader Submissions of 2014
https://nshipster.com/new-years-2014/#creating-a-keypath-from-selectors