开发者

Returning XML result of webrequest from one class to another class

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 req开发者_如何学JAVAuest 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.


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜