开发者

How do I make a reusable web interface class in objective C?

开发者 https://www.devze.com 2023-02-13 02:50 出处:网络
I\'m working on a new iPhone/iPod app that includes the need to do web services requests.I\'ve found methods for doing these requests synchronously, or asynchronously by setting the controller as the

I'm working on a new iPhone/iPod app that includes the need to do web services requests. I've found methods for doing these requests synchronously, or asynchronously by setting the controller as the delegate. What I'd really like to be able to do, though, is to create a single class that can handle all web requests for the whole application, and just create an instance of that class when I need to use it. That way, cookies and common pieces of code can be handled in one place, rather than all over the app.

So far the only thing I thought of that could accomplish what I'm trying to do is to create a new thread that handles the request synchronously within itself, then sends a message back to the calling controller once the request开发者_StackOverflow is complete. Is there a better way to accomplish what I'm trying to do?


Cookies are already a shared resource.

I would suggest reading the URL Loading System Overview to get an idea of how Apple set everything up. From what you describe, you want something very similar to how they have set up the system, maybe with a Singleton class for the connection. You can also look at ASIHTTPRequests which is a good wrapper around all of the connections stuff.
I would not suggest writing my own code here. Lots and lots of people have solved this problem for you.

0

精彩评论

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

关注公众号