Created
July 9, 2012 11:33
-
-
Save isutton/3075958 to your computer and use it in GitHub Desktop.
NSInvocation usage example.
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
// Omitting the ownership qualification here can lead to a EXC_BAD_ACCESS exception in ARC enabled projects. | |
__weak id returnValue = nil; | |
SEL selector = @selector(colorFromString:); | |
NSString *valueString = @"0.2 0.2 0.2 1.0"; | |
// Create and configure the NSInvocation object. | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[target methodSignatureForSelector:selector]]; | |
invocation.selector = selector; | |
invocation.target = target; | |
[invocation setArgument:&valueString atIndex:2]; | |
[invocation invoke]; | |
[invocation getReturnValue:&returnValue]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment