我的 NSTreeController 正在设置 Core Data 父属性而不是子属性。
我有一个像这样的核心数据模型
Item
title (string)
isLeaf (boolean,readonly)
parent -> Group (inverse children)
Group (parent entity Item)
children -> Item (inverse parent)
Leaf (parent entity Item)
然后我用 NSOutlineView 和 NSTreeController 显示它。我使用方法 -[NSTreeController insertObject:atArrangedObjectIndexPath:] 尝试插入 Leaf,叶子的父属性设置正确,但父 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,为什么当我有一个 NSManagedObject 子类 SavedItem、SavedGroup 和 SavedLeaf 时它使用 NSMutableDictionary。我已经下载了几个示例,但我看不到他们在做什么,而我不是。