1
私は、繰り返し実行する必要があるRLMResultsを持っています。(長時間実行している)ダウンロードタスクを実行してください。このダウンロード結果が表示されます。 (答えのためのドキュメントを精練した後)私がしようとしたもので、最新の繰り返し意図したとおり、これは明らかに動作しませんが、このようなものですが、デモの目的のためにその出発点:レルム - バックグラウンドスレッドでRLMResultsを一括更新する
RLMResults *objectsToSaveImagesFor = [self allObjectsToSaveImagesFor];
for (Object *object in objectsToSaveImagesFor) {
RLMThreadSafeReference *objectRef = [RLMThreadSafeReference referenceWithThreadConfined:object];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
RLMRealm *realm = [RLMRealm realmWithConfiguration:self.realm.configuration error:nil];
Object *threadSafeObject = [realm resolveThreadSafeReference:objectRef];
BOOL success = [self downloadImageForObject:threadSafeObject];
[realm transactionWithBlock:^{
threadSafeObject.imageSaved = success;
}];
});
}
Iこれについて数十回の試行を試みましたが、私がやりたいことをやり遂げる正式なレルムの方法を理解することができません。何千ものイメージをダウンロードし、それぞれのレルムを更新しますバックグラウンドスレッドでのダウンロードの結果を持つオブジェクト。一度だけそれを行う、作成しRLMResults
内の各オブジェクトのためのスレッドセーフな参照を解決するのではなく
あなたが全体にスレッドセーフな参照を得ることができる私には発生しませんでしたRLMResults ...それは、ありがとう! – Mike