1

ViewControllerA を使用AFNetworkingしてファイルをダウンロードsetDownloadProgressし、進行状況でモデルを更新できます。UITableViewまた、すべての転送のリストを持つ ViewControllerB もあります。

内部cellForRowAtIndexPathで私は自分のモデルを観察します

[transfer addObserver:cell
           forKeyPath:@"completed"
              options:NSKeyValueObservingOptionNew
              context:NULL];

これは機能し、次のような進行状況を読み取ることができます

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if ([keyPath isEqualToString:@"completed"]) {
        float val = [[change objectForKey:@"new"] floatValue];
        NSLog(@"%f", val);
    }
}

しかし、UITableViewCell を KVO で更新する方法がわかりません。

4

1 に答える 1