Core Data NSFetchedResultsController - Asynchronous Option

Originator:brentsimmons
Number:rdar://15183257 Date Originated:10/8/2013
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 7
Classification:Feature (New) Reproducible:
 
Summary:

NSFetchedResultsController is cool -- but it does block the main thread while fetching.

I'd like an option to *not* do that, to have it run its fetch in the background, and report changes to its delegate (on the main thread) the way it already does.

Comments

Not the case.

This is only the case if you are using thread confinement. If you are not, you can do this using a private queue directly. Your delegate callbacks will not arrive on the main thread, but that is up to you to handle. NSFetchedResultsController performs it's fetches using NSManagedObjectIDResultType for this very reason. You can also have your NSFetchedResultsController use a NSMainQueueConcurrencyType context that is a child of an NSPrivateQueueConcurrencyType and this can be used to severely limit being blocked going to disk. This is covered in depth in several WWDC sessions. Note that on iOS 5, NSFetchedResultsController has bugs that would make this less of an attractive option (it can deadlock, don't ask)

Need this so bad

Working on a data set that can have potentially tens of thousands of entries, and with an NSFetchedResultsController and with a UITableView that has rows of different heights. My only option is to paginate results and fetch in batches. Every time I call NSFetchedResultsController performFetch again, and it just blocks the UI the whole time the fetch is happening.

By apoorvkhatreja at Oct. 9, 2013, 8:52 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!