【发布时间】:2012-03-12 10:45:43
【问题描述】:
我的 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。我已经下载了几个示例,但我看不到他们在做什么,而我没有。
【问题讨论】:
标签: objective-c cocoa core-data nsoutlineview nstreecontroller