本文介绍了集合<NSCFSet:0x1b0b30>在枚举时发生了突变.如何确定哪个集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一堆核心数据插入,在 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 导致了这种情况.我进行了搜索,我的代码中唯一的 NSSet 是处理核心数据关系的自动生成的.

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.

这篇关于集合&amp;lt;NSCFSet:0x1b0b30&gt;在枚举时发生了突变.如何确定哪个集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:08