cocoa MVC design question

  • I want to use NSTreeController to provide a hierarchy of data for the
    user using NSOutlineView.

    My problem is each "level" of the hierarchy is populated differently
    from my model (file system, sql... etc). Therefor, I can't just use
    NSMutableDictionary like I have in the past.

    From an MVC stand point what is the best solution?

    I can see several options:

    1. Subclass NSTreeController putting definitive structure logic here.
    Calling my other controllers as necessary to actually obtain and
    display the data. (I'm not entirely sure how this would work but I
    know people do it for a variety of reasons, so I mention it first).

    2. Create a wrapper class/object (or perhaps a Protocol) that wraps
    *all* of my various types of model objects from the hierarchy. Each
    class object would conform to this protocol (displayName and other
    accessors would be part of it). What does the children key path need
    to return in this case? An NSArray of the children objects?

    Is #2 what the documentation means when it says:

    "All child objects for the tree must be key-value-coding compliant
    for the same child key path. If necessary you should implement
    accessor methods in your model classes, or categories on those
    classes, that map the child key to the appropriate class-specific
    method name."

    3. A third option I'm not aware of? Are there advantages or
    disadvantages I should be aware of between these two methods?


previous month october 2006 next month
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today