views:

27

answers:

2

If I have a method like this:

- (void) foo
{
}

Then I can access it through a selector like this:

@selector(foo)

But what if I have a method like this:

- (void) bar:(NSString *)str arg2:(NSString *)str2
{

}

Then how do I access it through a selector?

+2  A: 

Remove the spaces, parameter types, and parameter names. In your example, this would become:

@selector(bar:arg2:)
Robot K
Then how do you pass the parameters?
awakeFromNib
See Joshua's answer for how to invoke the selector.
Robot K
+4  A: 

To handle an arbitrary number of selectors you should use NSInvocation, but you can handle up to two objects using the standard performWithSelector stuff

[foo performSelector:@selector(bar:arg2:) withObject:obj1 withObject:obj2]

Joshua Weinberg