Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Setup NSURLConnection
- NSURL *URL = [NSURL URLWithString:url];
- NSURLRequest *request = [NSURLRequest requestWithURL:URL
- cachePolicy:NSURLRequestUseProtocolCachePolicy
- timeoutInterval:30.0];
- NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
- [connection start];
- [connection release];
- // NSURLConnection Delegates
- - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
- if ([challenge previousFailureCount] == 0) {
- NSLog(@"received authentication challenge");
- NSURLCredential *newCredential = [NSURLCredential credentialWithUser:@"USER"
- password:@"PASSWORD"
- persistence:NSURLCredentialPersistenceForSession];
- NSLog(@"credential created");
- [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
- NSLog(@"responded to authentication challenge");
- }
- else {
- NSLog(@"previous authentication failure");
- }
- }
- - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
- ...
- }
- - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
- ...
- }
- - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
- ...
- }
- - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement