0

Is it possible to get the argument from the selector varibale.

For Example

-(void)methodTest:(NSString*)someArg{

    SEL selector = @selector(methodTest:);
    [self testCall:selector];
}

-(void)testCall:(SEL)selectorArg{

    //I would like to get the parameter from the selector (selectorArg)
}

My Questions: 1. Does the selector has the argument, someArg? If not, how to create the selector variable with argument. 2. What is the other way around to do the same?

Just curious to know.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Alex
  • 229
  • 3
  • 15

2 Answers2

0

I'm not totally understand what you searching for, but I'm guessing you need performSelector method. Please check this SO thread: iOS - How to implement a performSelector with multiple arguments and with afterDelay?

Community
  • 1
  • 1
David V
  • 2,134
  • 1
  • 16
  • 22
0

If you create a selector like:

SEL selector = @selector(methodTest:);

It means (Note the :) that the selector expects an argument.

You can pass argument to such method like:

[self performSelector:selector withObject:argument afterDelay:0.0];

And the method syntax will be:

- (void)methodTest:(id)someArgument;

If the selector is created by the following syntax:

SEL selector = @selector(methodTest);

Then you can't pass any argument to this selector. You can call like:

[self performSelector:selector withObject:nil afterDelay:0.0];

And the method syntax will be:

- (void)methodTest;
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • I appreciate the way you responded, despite the immature question. I realised now. Thanks. – Alex Jun 18 '14 at 09:56