NSOutlineView with NSTreeController bindings with

2019-06-14 18:13发布

问题:

Please send me some links on how to use NSOutlineView with NSTreeController bindings with using core data.

https://www.dropbox.com/s/em7kxjqmxqjto88/outlineViewCoreData%20copie.zip?dl=0 this example is ok

https://www.dropbox.com/s/1asg3kkf9ltwj2w/outlineViewCoreData.zip?dl=0 this example is ko. ==> why

the entity EntityCategory is not key value coding-compliant for the key "category".

回答1:

I have found the solution

All is ok

https://www.dropbox.com/s/nnh0e0atwmrqpmm/outlineViewCoreDataOK.zip?dl=0

i have add

extension EntityCategory {

    @objc var  children : NSSet {
        return []
    }

    @objc var count : Int {
        return 0
    }

    @objc var isLeaf : Int {
        return 1
    }

}

and

extension EntityAffectation {

    @objc var  children : NSSet {
        return category!
    }

    @objc var count : Int {
        return category!.count
    }

    @objc var isLeaf : Int {
        return 0
    }

}

and

tree controller keyPaths