Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to pass the method name as argument string

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 344
    Comment on it

    Sometime we don't know name of the method at compile time. So pass the method name as argument and use the following lines of code.

    NSString *methodname=@"calltest";
    SEL aSelector = NSSelectorFromString(methodname);
    
    NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
    [inv setSelector:aSelector];
    [inv setTarget:self];
    int AVCaptureAutoFocusRangeRestrictionFarValue = 2;
    [inv setArgument:&AVCaptureAutoFocusRangeRestrictionFarValue atIndex:2];
    [inv invoke];
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: