Hi!
In my small Core Data application I have some NSTableView views binded with NSArrayController controllers in Entity mode.
When I try to import some big amount of data to my table in background thread, after some successfully added imports (from dozens to hundreds items) I get crash with log:
Serious application error. Exception was caught during Core Data change processing: *** Collection was mutated while being enumerated.NSHashTable (%@) { [5] (entity: Word; id: 0x1001dd4b0 ; data: { ....... entity description here.... } ....
...and stack trace:
#0 0x7fff83e0e2fa in mach_msg_trap
#1 0x7fff83e0e96d in mach_msg
#2 0x7fff8816c614 in _CGSSynchronizeWindowBackingStore
#3 0x7fff88152169 in _CGSLockWindow
#4 0x7fff88158cff in CGSDeviceLock
#5 0x7fff81ecae43 in ripd_Lock
#6 0x7fff81eca746 in ripl_BltShape
#7 0x7fff81ec7d86 in ripc_Render
#8 0x7fff81ec5317 in ripc_DrawRects
#9 0x7fff88158641 in CGContextFillRects
#10 0x7fff8818ee1a in CGContextFillRect
#11 0x7fff86e712f8 in NSRectFillUsingOperation
#12 0x7fff86f2152e in NSDrawWindowBackground
#13 0x7fff86ea16c2 in -[NSThemeFrame drawWindowBackgroundRect:]
#14 0x7fff86e6eb9a in -[NSFrameView drawThemeContentFill:inView:]
#15 0x7fff86e68aa5 in -[NSThemeFrame drawRect:]
#16 0x7fff86e68131 in -[NSView _drawRect:clip:]
#17 0x7fff86e65907 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#18 0x7fff86e64ee8 in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#19 0x7fff86e6179a in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
#20 0x7fff86ddaff6 in -[NSView displayIfNeeded]
#21 0x7fff86dd5ea2 in _handleWindowNeedsDisplay
#22 0x7fff80099a2d in __NSFireTimer
#23 0x7fff815aa678 in __CFRunLoopRun
#24 0x7fff815a884f in CFRunLoopRunSpecific
#25 0x7fff82c3991a in RunCurrentEventLoopInMode
#26 0x7fff82c3971f in ReceiveNextEventCommon
#27 0x7fff82c395d8 in BlockUntilNextEventMatchingListInMode
#28 0x7fff86dab29e in _DPSNextEvent
#29 0x7fff86daabed in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#30 0x7fff86d708d3 in -[NSApplication run]
#31 0x7fff86d695f8 in NSApplicationMain
Assuming there is an issue with updating table (enumeration not being thread safe), I have tried to solve this problem by disabling controller and table before import starts using:
[wordsController setEditable:NO];
[wordsController setAutomaticallyPreparesContent:NO];
[wordsTable setEnabled:NO];
but it does not help. During import I still see new entities being added to the tale until crash.
Anyone knows what is the trick to disable NSArrayController from tracking changes for a time of background processing? Or maybe it is other issue here?
Thank You very much for any hints.