In one of my apps, I'd like to call asynchronously a php page I have written (http://serveradress/page.php?date=20111231), and I would be sure to know if the page could be called (no 404 error, php server down, customised 404 page, missing internet connection, or some things like that). I've planned for that to make the php page return a very simple HTML page with just "OK" in its body or title.
This would be a "phantom" call without use of any UIWebView, or if REALLY nedded, a hidden UIWebView but I'd prefer to avoid this.
Could you help me to write this call ?
And be sure to know if it has been loaded ?
I saw that I should probably use NSURLConnection, but I'm a little bit lost.
Could you help me ?
NSURLConection is very good solution for asynchronous loading. There are few steps for creating one.
1. Setup your NSURLConnection
responseData
is your NSMutableData iVar.2. Implement delegate methods
a) In this method we will check for HTTP status codes
b) This creates your NSData component
c) Handles successful url connection
d) Handles errors
You can get error info using
[error userInfo]
And display it in UIAlertView, for example.So as I said NSURLConnection is very good solution, but you should also look at ASIHTTPRequest library. :)