objective c - How to create SourceList to show Core Data ToMany relations? -


coming ios, stuck @ nsoutlineview source list, have read many resources cannot grasp clearly.

what want is, show coredata tomany relationship sourcelist using nstreecontroller. persisting data text file disk. entities , relations follow:

group >> item >> description

data model

sourcelist example:

enter image description here

my app not allow user create new entity, view saved textfile. can nsarraycontroller need show data in single table hierarchy. in nsarraycontroller, needed bind managed object context parameter , and object controller entity name. on tableview needed bind content , selection indexes nsarraycontroller.

how can bind nstreecontroller sourcelist , when children selected, show tomany relation item description.

i can think of 2 solutions , maybe there better one.

solution 1: create subclass of nstreecontroller , override

- (nsstring *)childrenkeypathfornode:(nstreenode *)node 

the managed object node.representedobject.

solution 2: create nsmanagedobject subclasses , implement children method returns child relationship.

- (nsset *)children {     return self.itemsingroup; } 

set childrenkeypath of tree controller 'children'.

i think solution 2 feels wrong, managed objects shouldn't contain code views, easy implement if have nsmanagedobject subclasses.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -