views:

217

answers:

3

hello,

If this is the method name which has to be called:

-(Authenticate_Obj)Authenticate_User:(NSString*)Number:(NSString*)name:(NSString*)password

how to call this method from the @selector ??

can i do it in this way??

[tis_obj AuthenticateMobileServer:self action:@selector(AuthenticateUser:::)];

Thank You.

+2  A: 

You can do it like this: @selector(Authenticate_User:Number:name:)

Chris Eidhof
+1  A: 

As Chris pointed correct syntax to declare selector for a method with multiple parameters is

@selector(Authenticate_User:Number:name:) 

However you can't call method that takes more then 1 parameter using -performSelector method (and similar) - you have to use NSInvocation class for that

Vladimir
That isn't right... easy mistake to make given the non-standard declaration.
bbum
hm, where the mistake is? (I assumed that there's Authenticate_User parameter name missing in declaration)
Vladimir
The selector is incorrect. Given his declaration, it is `Authenticate_User:::`. The `number`, `name` and `password` bits are argument names.
bbum
+4  A: 

Given this:

-(Authenticate_Obj)Authenticate_User:(NSString*)Number:(NSString*)name:(NSString*)password

Your method's selector is:

Authenticate_User:::

Which is the string you would pass to @selector().

Your AuthenticateMobileServer:action: method must takes a selector that, when called, takes that set of arguments, obviously.

There are, however, several problems with this code (the first clue being the two wrong answers from otherwise very knowledgeable folk).

  1. Method names do not start with capital letters, nor do they have _s in them. Method names are camel-cased. So, something like authenticateUserNumber:name:password: would be a more appropriate method name.

  2. Every argument should have a part of the method name that describes it. Again, authenticateUserNumber:name:password: would be in line with standard practice.

  3. Class names don't have _ in them. I'm assuming Authenticate_Obj is a class. If so, it also needs to be returned as a pointer.

Namely, that method should probably be something like:

- (AuthenticateObject *) authenticateUserNumber: (NSString*) aNum
                                           name: (NSString *) aName
                                       password: (NSString *) aPassword;
bbum