我已经阅读了有关在文档中使用 ASIHTTPRequest 在我的应用程序中实现自定义进度跟踪的信息。它提到了实现 2 种方法,request:didReceiveBytes:
并且request:incrementDownloadSizeBy:
. 我已将这些添加到我的视图控制器中,但它们没有被调用。我只是想让示例代码在这一点上工作。
// ViewController.m
- (void)fetchThisURLFiveTimes:(NSURL *)url
{
[myQueue cancelAllOperations];
[myQueue setDownloadProgressDelegate:self];
[myQueue setDelegate:self];
[myQueue setRequestDidFinishSelector:@selector(queueComplete:)];
int i;
for (i=0; i<5; i++) {
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
request.showAccurateProgress = YES;
[myQueue addOperation:request];
}
myQueue.showAccurateProgress = YES;
[myQueue go];
}
- (void)queueComplete:(ASINetworkQueue *)queue
{
NSLog(@"Value: %f", [myProgressIndicator progress]);
}
- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes
{
NSLog(@"bytes: %lld", bytes);
}
- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength
{
NSLog(@"newLength: %lld", newLength);
}
我在这里做错了什么?