Initial coredata save freezes app

China☆狼群 提交于 2019-12-24 08:09:36

问题


I have an iOS application using coredata with three different models. The data is pulled from a json feed from a server then saved. Each API call is run on a thread using NSOperationQueue so they never execute at the same time. On the final call I save to the largest model being stored it is after the save happens that the application hangs. The UI becomes unresponsive and the debugger gives no errors. This only happens on the first load of the app, afterwards every subsequent load runs perfect. I have tried loading only the final api call and the error still happens. I receive the delegate callback controllerDidChangeContent: and do nothing in the method. I am stumped. Thank you folks for you assistance.


回答1:


It is "freezing" your app because you are most likely merging the save back to the main NSManagedObjectContext via the NSManagedObjectContextDidChangeNotification. This is known limitation prior to iOS 5.0.

Either you can update to 5.0 and use the parent child MOC design that was added or you can skip merging the contexts and -reset the main context and force it to reload relevant data after the save.



来源:https://stackoverflow.com/questions/8171869/initial-coredata-save-freezes-app

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