Ok, I’m trying to get a file from my webserver. But I’m getting kinda confused about some stuff. When I use NSURL I can get my xml-file with an url like this: “localhost…../bla.xml”. But I’m also trying to test some things… Like… What will happen to my app if I have an open connection to the webserver, and I lose connection to internet? The above method with the NSURL, I haven’t really established any connection where it always is connected right? or should I use be using NSURLConnection?
Maybe it’s a little confusing, because I’m confused. I hope someone can give me some info I can research about.
Thanks.
Take a look at NSURLConnection Class.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html
Create connection object and set a timeout value, if you lose the connection or the connection times out NSURLConnection delegate method:
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)errorgets called and you would be notified of that event.You might also use
NSURLConnectionsendSynchronousRequestmethod, but its strongly discouraged to use that method as it would block the thread its running.