问题描述
我正在做一堆核心数据插入和20k左右插入后保存每1-2k我得到这个错误:
I'm doing a bunch of core data inserts and after 20k or so inserts with saves every 1-2k I get this error:
Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <NSCFSet: 0x1b0b30> was mutated while being enumerated.'
我试图找出哪个NSSet导致这个。我做了一个搜索,我的代码中的唯一的NSSets是自动生成的处理核心数据关系。
I'm trying to figure out which NSSet is causing this. I've done a search and the only NSSets in my code are the autogenerated ones that handle the Core Data relationships.
我使用NSXMLParser和每个元素找到创建新实体(如果匹配的实体不存在)。
I'm using NSXMLParser and for each element found creating a new entity (if a matching one doesn't already exist).
所以我将创建一个状态实体,然后填充所有的城市实体,然后做一个保存。这意味着一个状态的NSSet * cities已经添加,但我不知道为什么你不能这样做。
So I will create a state entity and then populate all the city entities and then do a save. This means that a state's NSSet *cities is getting added to but I don't see why you can't do that.
推荐答案
在 objc_exception_throw
上设置断点并获取回溯。这应该指示突变期间枚举的内容。
Set a breakpoint on objc_exception_throw
and grab a backtrace. That should indicate what is enumerating during mutation.
这篇关于集合< NSCFSet:0x1b0b30>被枚举时发生突变。如何确定哪个集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!