views:

41

answers:

3

Are there any equivalents in objective-c to the following python urllib2 functions?

Request, urlopen, HTTPError, HTTPCookieProRequest, urlopen, HTTPError, HTTPCookieProcessor

Also, how would I able to to this and change the method from "get" to "post"?

+1  A: 

You're looking for some combination of NSURL, NSURLRequest, NSURLConnection, NSHTTPConnection, etc. Check out the URL Loading System Programming Guide for all the information you need.

Carl Norum
A: 

NSMutableHTTPURLRequest, a category of NSMutableURLRequest, is how you set up an HTTP request. Using that class you will specify a method (GET or POST), headers and a url.

NSURLConnection is how you open the connection. You will pass in a request and delegate, and the delegate will receive data, errors and messages related to the connection as they become available.

NSHTTPCookieStorage is how you manage existing cookies. There are a number of related classes in the NSHTTPCookie family.

With urlopen, you open a connection and read from it. There is no direct equivalent to that unless you use something lower level like CFReadStreamCreateForHTTPRequest. In Objective-C everything is passive, where you are notified when events occur on the stream.

drawnonward
Thank you for the detailed information! This will definitely make the app easier to create now.
SachaK
A: 

A previous similar question.

ASIHTTPRequest is a good library.

Jaanus