29,049
社区成员




- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSInteger status = [(NSHTTPURLResponse *)response statusCode];
if (status != 200)
[self cancel:connection];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
/////// to do your logic
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[self cancel:connection];
}
- (void)cancel:(NSURLConnection *)connection {
[connection cancel];
/////////to do your logic.
}
看苹果文档的解释
After this method is called, the connection makes no further delegate method calls. If you want to reattempt the connection, you should create a new connection object.