ios - does this strategy that use core data with multiple thread will block main thread ? -


i have read many blogs recommend use core data in multiple thread following pattern. enter image description here

but question if there lot of records have load when app starts, have use nsfetchdresultscontroller fetch records in coredata. because run in main thread(main moc), block main thread? if want fetch records, can use temporary background moc fetch? , how it?

you configure batching on fetch request nsfetchedresultscontroller. when perform fetch in nsfetchedresultscontroller, , in turn executes fetch request, request minimal, because fetches object ids , no data. later, when object results accessed (typically in -tableview:cellforrowatindexpath:), first batch being fetched. fetch takes little time (if configure small enough batch size). when scroll , access first object not in batch, next batch fetched , on. way no big fetches performed on main thread.

there 1 problem approach , pattern you've chosen. reason batching doesn't work when fetch request executed in child context. works in contexts connected persistent store coordinator directly.


Comments