NSFetchedResultsController crashing on performFetch: when using a cache

后端 未结 12 2141
迷失自我
迷失自我 2020-12-23 14:05

I make use of NSFetchedResultsController to display a bunch of objects, which are sectioned using dates. On a fresh install, it all works perfectly and the objects are displ

12条回答
  •  旧巷少年郎
    2020-12-23 14:13

    I encountered a similar problem. When I inspected the Debugger Console, it showed what the cached objects and the fetched objects were so that I could figure out why they are inconsistent. In my case it was due to a different predicate.

    Since the values in my predicate are not dynamic, I could specify a different cache name for each predicate. That will create a cache for each 'type' I specify.

    I suppose you will have to assess your need to have the cache. To specify nil, means that a fetch is made in every call.

    I figured out that the error occurs only when the fetch request have some changes. If you are creating a new NSFetchRequest OR changing the predicate OR sort descriptor, then you should delete the cache or use a different cache. Otherwise, ensure that you have the same NSFetchRequest or make sure that your NSFetchedResultsController is retained and that should solve your problem.

提交回复
热议问题