NSURLConnection 代理
@interfaceDownloadDelegate:NSObject
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response;
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data;
@end
@implementationDownloadDelegate
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response {
}
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data {
}
@end
We use the delegate like so:
DownloadDelegate*dd =[DownloadDelegate alloc];
NSURLConnection*c2 =[[NSURLConnection alloc] initWithRequest:url delegate:dd];