NSFetchedResultsController crashing on performFetch: when using a cache

后端 未结 12 2173
迷失自我
迷失自我 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:29

    I started getting the same error when I upgraded by MacBook Pro to Snow Leopard 10.6.4 and the latest SDK.

    As it turns out, many of us had been using code that wasn't in conformance with the rules, but we didn't know it because CoreData wasn't really behaving in accordance with its own rules.

    Specifically, when you fetch things, they get cached, and in 4.0, that cache isn't automatically purged in cases where it was purged in the earlier SDK.

    For me, the solution was simple. I just employed the class method that purges the caches. You can specify an individual entity, but I specify nil so it just does them all in this particular piece of start-up code:

    [NSFetchedResultsController deleteCacheWithName:nil];
    

    Suddenly, the little app I've worked on only to familiarize myself with CoreData is working again.

提交回复
热议问题