Collection <NSCFSet: 0x1b0b30> was mutated while being enumerated. How to determine which set?
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.'
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.
I'm using NSXMLParser and for each element found creating a new entity (if a matching one doesn't already exist).
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.
Set a breakpoint on objc_exception_throw
and grab a backtrace. That should indicate what is enumerating during mutation.
精彩评论