I am setting up a NSURLConnection to access a remote server:
NSURL *url = [[NSURL alloc] initWithString:projectURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
Using the following delegate methods below:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
All of theses methods say “Available in iOS 2.0 through iOS 4.3.” My question should I be doing this another way for the current iOS5? I need asynchronous transfer and need to pass a NSURLCredential for UID/PWD authentication.
EDIT:
So if I am adopting the protocol <NSURLConnectionDelegate> in my header and using the delegate methods above I am doing this the right way?
For iOS 5, looks like you can take advantage of the new
NSURLConnectionDelegateprotocol (documentation linked for you).And here’s a related (or maybe even duplicate?) question that explains even better.