I'm new to Core Data. I'm working against a large database, so batching/faulting mechanism is important to me.
I understand how this works when using an NSFetchedResultsController paired with a UITableView, but what if I'm not using this pairing, i.e. what if I'm allowing users to navigate sequentially through a detail view controller (similar to how Apple's Mail program does it at the message level)?
Right now, I load the sorted fetch results into an NSArray and can traverse that as needed. But if I limit the batch size to 20 for the fetched results, what do I do when the user wants to navigate to object # 21?
While NSFetchedResultsController is designed to be used with a UITableView, you can still use it stand alone.
When creating a fetch request, setLimit determines how many total objects are returned. setBatchSize determines how many of those objects are un-faulted at a time. So, initially, all but the first 20 objects retrieved will be returned as faults. When you access item 21, it will fetch (un-fault) another 20 objects in the results set.
You use the fetchOffSet
method to have the fetch request start the next batch fetch after the point you've already fetched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With