Thursday, October 20, 2011

iOS NSURLConnection

responseData = [[NSMutableData data] retain];

NSURLRequest *request = [NSURLRequest requestWithURL:

                             [NSURL URLWithString:@"http://www.url.com"]

cachePolicy:NSURLRequestReloadIgnoringLocalCacheData

timeoutInterval:60.0];

NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

[connection start];

#pragma mark NSURLConnection delegate methods

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {

[
responseData setLength:0];

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

[
responseData appendData:data];

}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {

}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

}

No comments: