NSOutline/NSTable-View: delegate or bindings?

  • I have an NSOutlineView that will be populated with a list of objects
    that is synthesized by a custom controller. My question is, is it
    better to make the custom controller the delegate of the outline view,
    or make it a subclass of NSTreeController to override -
    arrangedObjects? If the latter, I noticed that -arrangedObjects
    returns a "proxy root tree". What is that?

    Thanks,

    Mike
  • On 14-Dec-07, at 5:39 PM, Mike R. Manzano wrote:

    > I have an NSOutlineView that will be populated with a list of
    > objects that is synthesized by a custom controller. My question is,
    > is it better to make the custom controller the delegate of the
    > outline view, or make it a subclass of NSTreeController to override -
    > arrangedObjects?

    I would not subclass NSTreeController if possible. I would bind the
    tree controller's content to the object which synthesizes the tree.

    > If the latter, I noticed that -arrangedObjects returns a "proxy root
    > tree". What is that?

    It is an implementation detail :)

    dave

    > Thanks,
    >
    > Mike
    >
  • >> If the latter, I noticed that -arrangedObjects returns a "proxy
    >> root tree". What is that?
    >
    > It is an implementation detail :)

    It is important to note that if you are developing on Leopard that the
    proxy object _NSControllerTreeProxy inherits from NSObject NOT
    NSTreeNode as you might expect. This pattern is observed by
    _NSControllerArrayProxy and _NSControllerArrayProxyMutatorArray
    (proxies returned by NSArrayController) which inherit from NSArray and
    NSMutableArray respectively.

    The effect this has is that you can call NSArray category methods on
    the object returned by an array controller's -arrangedObjects method
    but you CAN'T call NSTreeNode category methods on the object returned
    by a tree controller's -arrangedObjects method.

    I filed a bug prior to Leopard's release but it wasn't fixed, no
    indication as to wether it will be or not.

    The work around is to class-dump the AppKit to get the header for
    _NSControllerTreeProxy and then implement your category methods on
    both NSTreeNode and _NSControllerTreeProxy. Laborious I know, I tried
    to tell them this.

    - Keith
previous month december 2007 next month
MTWTFSS
          1 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