0

リクエストをしようとしていますが、最初の 1 回だけしか機能しません....

これが私のコードです:

NSArray *infos = [rows objectAtIndex:indexPath.row];
NSString *thumbPath = thePath;

NSURLRequest *thumbRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:thumbPath]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10];

self->thumbConnection = [[NSURLConnection alloc] initWithRequest:thumbRequest
                                                        delegate:self
                                                startImmediately:YES];

     self->thumbData = [[NSMutableData alloc]init];

レスポンス受信時

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

if (self->thumbData == nil) {
    self->thumbData = [[NSMutableData alloc]init];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

self.thumbImage.image = [UIImage imageWithData:self->thumbData];

self.thumbActivityView.hidden = YES;

self->thumbData = nil;
}

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

self.thumbImage.image = [UIImage imageWithData:self->thumbData];

self.thumbActivityView.hidden = YES;

[self->thumbData release];

self->thumbData = nil;

}

タイムアウトまたはその他のエラー メソッドの場合:

   - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[self->thumbData release];
self->thumbData = nil;
self.thumbActivityView.hidden = YES;
[thumbConnection release];
self->thumbConnection = nil;

}
4

1 に答える 1