Core-Data executeFetchRequest freezes App in a background thread

拜拜、爱过 提交于 2019-12-01 00:13:42

What is your goal with createPostInFeed? You show that you are doing a fetch but what do you do with that fetch? Is this a "insert or update" check? or is it just a "insert or skip" test?

Any fetch is going to lock the NSPersistentStoreCoordinator and cause your application to potentially lock up while the fetch is being performed. There are ways to mitigate that:

  1. Run Instruments
  2. Make your fetches more efficient
  3. If you don't need objects (in a insert or skip test) then do a count instead
  4. Fetch on a background queue and make sure your main MOC has all the objects it needs to avoid a lock

What does your instruments profile show you?

What does createPostInFeed do with the results of that fetch?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!