Created
January 15, 2014 21:54
-
-
Save seanwolter/8445515 to your computer and use it in GitHub Desktop.
retain return value from invocation
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
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