NSTreeControllerはコアデータの親属性を設定していますが、子属性は設定していません。
私はこのようなコアデータモデルを持っています
Item
title (string)
isLeaf (boolean,readonly)
parent -> Group (inverse children)
Group (parent entity Item)
children -> Item (inverse parent)
Leaf (parent entity Item)
次に、NSOutlineViewとNSTreeControllerを使用して表示しています。メソッド-[NSTreeControllerinsertObject:atArrangedObjectIndexPath:]を使用してLeafを挿入しようとすると、leafsの親プロパティは正しく設定されますが、親のGroup.childrenプロパティはnilに設定されたままになります。
プロジェクトを実行すると、コンソールに次の警告が表示されます
Warning: <NSTreeController: 0x7fcd93c19d20>[object class: NSMutableDictionary] childrenKeyPath cannot be nil. To eliminate this log message, set the childrenKeyPath attribute in Interface Builder
childrenKeyPathはInterfaceBuilderで設定されていますが、NSManagedObjectサブクラスのSavedItem、SavedGroup、およびSavedLeafがあるのになぜNSMutableDictionaryを使用しているのですか。いくつかの例をダウンロードしましたが、私がそうではないのに、彼らが何をしているのかわかりません。