0

i have a more or less general question about using coredata the most efficient way.

i have attempted two different approaches of managing data that is shown in a view of my project.

Approach 1: when the view gets loaded i perform all coredata fetches and store the results in an array, the view then retrieves the displayed objects from the array. (ie: objectAtIndex:...)

Approach 2: the viewcontroller itself lets my data handling class perform fetches on the go, whenever a specific coredata object is needed it gets fetched.

on my current project this involes about 200-500 objects that need to be sorted and displayed in a tableview according to their attributes.

the fetch methods are the same wether i load all objects first or when i load them in batches (of correct attributes).

the difference is mainly in the cellForRow method where i have to decide if i want to pick the objects out of an array or directly from coredata.

both methods work just fine, i dont really see any performance differences just now, but i fear that with scaling of the project & more data one or the other way might be slower.

what do you think is the better way to do this?

4

1 に答える 1

2

NSFetchedResultsControllerより大きなデータセットでは、おそらくテーブルサイズに基づいて永続ストアから適切な量のデータを取得するように最適化されたコントローラーを使用することで、ピークメモリフットプリントの点で利点がある場合があります。

フェッチされる管理対象オブジェクトのサイズと数NSFetchedResultsControllerなどに基づいてパフォーマンスを調整できるフェッチ バッチ サイズを制御できます。

于 2012-03-20T19:40:52.277 に答える