I am trying to use NSManagedObject
s with an NSTreeController
and NSOutlineView
in my macOS
app.
I have a two level data in the outline view: Project
and Item
, both are NSManagedObject
s set up in my model.
In my storyboard, I added this:
And I added this in my code:
extension Project {
@objc var isLeaf: Bool {
return false
}
@objc var childCount: Int {
return items?.count ?? 0
}
@objc var children: [Item] {
return items?.allObjects as! [Item]
}
}
extension Item {
@objc var isLeaf: Bool {
return true
}
@objc var childCount: Int {
return 0
}
@objc var children: [NSManagedObject] {
return []
}
}
When I run the app, I get the following error:
Thread 1: "[<MyApp.ProjectBrowserViewController 0x600001580820> valueForUndefinedKey:]: this class is not key value coding-compliant for the key isLeaf."
It doesn't say which class but that error shows up twice, so I am guessing once for Project
, and one for Item
.
What am I missing here, how do I fix this? Will gladly add more info if needed.