• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

集合和amp;amp;lt;NSCFSet:0x1b0b30和amp;gt;在枚举时发生了突变.确定哪个集合?

用户头像
it1352
帮助1

问题说明

我正在做一堆核心数据插入,在 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.

正确答案

#1

objc_exception_throw 上设置断点并获取回溯.这应该表明突变期间正在枚举什么.

Set a breakpoint on objc_exception_throw and grab a backtrace. That should indicate what is enumerating during mutation.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfjega
系列文章
更多 icon
同类精品
更多 icon
继续加载