I'm working on a iOS project and I'm asking myself a question for a couple of days. My problem is simple: I have webservice calls which are synchronous. But I would like to do asynchronous calls. But I don't kn开发者_如何学Cow where to define the fact calls should be asynchronous.
Here is how my code works: - I have a controller (most of the time, a UITableViewController) The controller calls a DataAccess with some arguments to get data - DataAccess calls a webservice using given arguments, transform result into an NSArray containing Model object, and return result to the controller
Should it be the controller or the DataAccess which defines that my call will be asynchronous?
Thanks for the help ;)
Depends on how your communicating with your web service. My company developed a REST implementation for this purpose (easier than SOAP for iOS purposes), and use asihttprequest to do the async calls. Asihttprequest is used by many apps and very good imo. Also, for data centric apps, we chose to put the calls in the model layer rather than the controllers.
ASIHTTPRequest. It's a third-party library that wraps and VASTLY simplifies HTTP client work.
It sounds to me like you're not hip to the delegate pattern yet. It's a critical part of working with Cocoa, so learn it up.
精彩评论