Skip to content

Instantly share code, notes, and snippets.

@seanwolter
Created January 15, 2014 21:54
Show Gist options
  • Save seanwolter/8445515 to your computer and use it in GitHub Desktop.
Save seanwolter/8445515 to your computer and use it in GitHub Desktop.
retain return value from invocation
NSString *selectorString = [NSString stringWithFormat:@"cellForSection%dRow%d:",indexPath.section,indexPath.row];
SEL cellSelector = NSSelectorFromString(selectorString);
if ([self respondsToSelector:cellSelector]) {
NSInvocation * invocation = [ NSInvocation new ];
NSMethodSignature *signature;
CFTypeRef result = NULL;
signature = [self.class instanceMethodSignatureForSelector:cellSelector];
invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:cellSelector];
[invocation setArgument:&indexPath atIndex:2];
[invocation invokeWithTarget:self];
[invocation getReturnValue:&result];
UITableViewCell *returnedCell = (__bridge UITableViewCell *)result;
return returnedCell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment