Friday 1 March 2013

Simple Post & Get Method ( HTTP Request ) in iOS (Objective-C)

Sending the startSynchronous message will execute the request in the same thread, and return control when it has completed (successfully or otherwise). 
Check for problems by inspecting the error property.
To get the response as a string, call the responseString method. Don’t use this for binary data - use responseData to get an NSData object, or, for larger files, set your request to download to a file with the downloadDestinationPath property.

now follow this code :-  


in Appdelegate.m

 call the above method  in application launching method
thats it, now you can check the response of the given URL in the console window..

For HTTP based errors check here :- http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

No comments:

Post a Comment