1

我想获得分数的进度,但我得到的是请求开始时的 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);

    }
 }

谁能告诉我如何以分数确定地取得进展?

4

0 回答 0