tags:

views:

16

answers:

1

hi friends ..

i am currently designing an app that utilises a number of webservices. So i have decided to write the webservice accessing part of my code in to a saperate class and each other classes(View controllers) will utilize this class by sending URL and Post fields and the webservice class will send request to server and return the resulting XML to the respective classes. But i have no idea of how am i going to do this.. How can i send the resulting XML back to respective classes. May be because i am new to iPhone app development... Please can anyone provide me a solution for this.

+1  A: 

When you create a request, pass in a callback - a target (id) and selector (SEL), for example, assuming a 'WebserviceRequest' class you create:

- (WebserviceRequest*) requestWithURL:(NSURL*)url target:(id)callbackTarget action:(SEL)callbackAction;

You'd call this function from your controller like so:

WebserviceRequest* myRequest = [WebserviceRequest requestWithURL:someurl target:self action:@selector(requestCompleted:)];

This will allow the WebRequest class to call the function 'requestCompleted' on the calling class by using performSelector:

[callbackTarget performSelector:callbackAction withObject:responseData];
Nicholas M T Elliott
thanks nicholas ....it worked..