iPhone Objective-C service handlers

Posted by Xavi Colomer on Stack Overflow See other posts from Stack Overflow or by Xavi Colomer
Published on 2010-04-19T21:55:26Z Indexed on 2010/04/19 22:13 UTC
Read the original article Hit count: 446

Filed under:
|
|

Hello community!

I am a as3 developer, I am used to use handlers everytime I launch an event and I am wondering which is the best way / practice to do that in Objective C.

Let's say I want to call a diferent services from my backend.

In as3 would be something like this to listent to the finish event:

service.addEventListener( Event.COMPLETE, handler_serviceDidFinished ) service2.addEventListener( Event.COMPLETE, handler_serviceDidFinished2 )

But how can I do the same in Objective C?

The problem is I already created the protocols and delegates, but how can I separate each response from the server?

For example:

-(void)callService:( NSString * )methodName withParameters:(NSMutableDictionary *) parameters
{
...
    if (self.delegate != NULL && [self.delegate respondsToSelector:@selector(serviceDidFinishSuccessfully:)]) {
        [delegate serviceDidFinishSuccessfully:data];
    }
}

Well I'm trying to create a generic delegate here, so how can I separate each response for every service?

My first idea is that maybe I should return the name of the service method in the delegate call to identify each service. Maybe I should create a UID for each service and pass it the same way...

Any idea?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone