tags:

views:

50

answers:

3

Hello,

How to make the @selector method execute 1st and then AuthenticateMobileServer in the below startement in Objective-C?Because AuthenticateMobileServer method is dependent on Handler logic.

 [mobile_Obj AuthenticateMobileServer:self action:@selector(Handler:)]; 

Please help.

Thank You.

A: 

@selector(...) doesn't call the method. How does the AuthenticateMobileServer:action: method normally work? We need more information.

jtbandes
A: 

Perhaps I'm lost, but why not just invoke it yourself first?

 [self Handler:...];
 [mobileObj AuthenticateMobileServer:self action:@selector(PostHandler:)];

As a note, method names in Objective-C generally follow lowerCamelCase convention.

dreamlax
i cant do that.. because i need the value from PostHandler:(id)value
suse
A: 

What you're doing is sending a message to mobile_Obj to execute the method AuthenticateMobileServer. The selector is passed along as an argument - but that doesn't mean the method it points to will actually be called. Whether this happens or not depends on what logic is working in AuthenticateMobileServer.

So, if AuthenticateMobileServer depends on whatever value "Handler" returns, you need to instantiate a class that implements "Handler" (or keep a reference to an existing instance and use it) right at the beginning of AuthenticateMobileServer's implementation, call "Handler" on it and grab the result.

Toastor