我想获得分数的进展,但我得到的是在请求开始时为0,在下载结束时为1。这是我写的代码
[self.resourceRequest.progress addObserver:self forKeyPath:@"fractionCompleted" options:NSKeyValueObservingOptionNew context:@"observeForrestLoad"];
- (void)observeValueForKeyPath:(nullable NSString *)keyPath ofObject:(nullable id)object change:(nullable NSDictionary *)change context:(nullable void *)context {
if((object == self.resourceRequest.progress) && [keyPath isEqualToString:@"fractionCompleted"]) {
// Do something with self.resourceRequest.progress.fractionCompleted
NSLog(@"progress= %f",self.resourceRequest.progress.fractionCompleted);
}
}
任何人都可以告诉我如何在分数中确定进度?