私の小さなCoreDataアプリケーションでは、エンティティモードでNSArrayControllerコントローラーにバインドされたNSTableViewビューがいくつかあります。
バックグラウンドスレッドでテーブルに大量のデータをインポートしようとすると、インポートが正常に追加された後(数十から数百のアイテム)、ログでクラッシュします。
重大なアプリケーションエラー。Core Data変更処理中に例外がキャッチされました:***列挙中にコレクションが変更されました。NSHashTable(%@){[5](エンティティ:Word; id:0x1001dd4b0;データ:{.......エンティティの説明はこちら....} ...。
...およびスタックトレース:
#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
テーブルの更新に問題があると仮定して(列挙はスレッドセーフではありません)、インポートが使用を開始する前にコントローラーとテーブルを無効にすることでこの問題を解決しようとしました:
[wordsController setEditable:NO];
[wordsController setAutomaticallyPreparesContent:NO];
[wordsTable setEnabled:NO];
しかし、それは役に立ちません。インポート中も、クラッシュするまで新しいエンティティがストーリーに追加されているのがわかります。
NSArrayControllerがバックグラウンド処理中に変更を追跡できないようにする秘訣は何ですか?それともここで他の問題ですか?
ヒントありがとうございます。