views:

415

answers:

1

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.

+6  A: 

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

bbum