配列コントローラー (辞書の配列を管理する) にバインドされた NSTableView を使用して、単純なインターフェイスを初期化しています。バックグラウンドで配列のコンテンツを読み込み (非常に時間のかかるプロセスです)、100 または 1000 要素ごとにテーブル ビューを更新したいと考えています。アイデアは、インターフェイスが利用可能で応答性が高いということです。後で更新/更新をトリガーする方法もわかりません。テーブルは空のままです。誰でもポインタを提供できますか?
私の現在のアプローチは次のとおりです。
// In init for my app controller. This seems to work well, but I've tried other methods here.
[self performSelectorInBackground:@selector(loadTable) withObject:nil];
- (void)loadTable {
tracks = [[NSMutableArray alloc] initWithCapacity:[masters count]];
// ... create each object one-by-one. Add it to tracks.
for (... in ...) {
[tracks addObject:newObject];
}
// Now I don't know what to do next. The table remains empty.
// Things I've tried (though possibly not in all combinations with the
// method above):
// 1. With a suitably-defined reloadData method, which just reloads
// the table view and sets needs display.
[self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];
// 2. Reload directly.
[tv reloadData];
[tv setNeedsDisplay];
}
データを直接ロードするだけで、バックグラウンドでそれを実行しようとしない場合、すべて正常に動作しますが、ほぼ 30 秒かかります。