NSNib: replacement objects

  • Hi!

    I used to do this with Java NIBs on WebObjects, but never figured out
    how to do this in Cocoa.

    Imagine I have a NIB set up with an NSArrayController. Is there a way
    to create the NSArrayController before loading the NIB, having the
    dearchiving process skip the NSArrayController, connect and bind to
    the already existing instance.

    The concrete example I have run into today: I need to access an
    NSArrayController created in my Document NIB from a NIB loaded at a
    later point in time. In this precise case the controller of the
    auxiliary NIB is instantiated from the Document NIB. So the easiest
    thing to do would be to connect the controller and the
    NSArrayController right within the Document NIB. But when I do so I
    cannot have the NSArrayController "icon" in the auxiliary NIB. Thus I
    need to bind manually.

    Actually I see one solution, but that seems a bit weird. I could have
    a NSController objectin my NIB to act as a proxy to an attribute of
    the controller. Actually, I did just that in HoudahSpot 1.x

    Pierre

    ---
    Pierre Bernard
    http://www.bernard-web.com/pierre
    http://www.houdah.com
  • Pierre,

    If your ArrayController is accessible as a property of the file's
    owner, then in IB you can bind your TableView's content to the file's
    owner using a model key path something like
    'arrayController.arrangedObjects' (and similarly for the
    TableColumns...)

    Cheers,
    dave

    On 6-Dec-07, at 3:39 PM, Pierre Bernard wrote:

    > Hi!
    >
    > I used to do this with Java NIBs on WebObjects, but never figured
    > out how to do this in Cocoa.
    >
    > Imagine I have a NIB set up with an NSArrayController. Is there a
    > way to create the NSArrayController before loading the NIB, having
    > the dearchiving process skip the NSArrayController, connect and bind
    > to the already existing instance.
    >
    > The concrete example I have run into today: I need to access an
    > NSArrayController created in my Document NIB from a NIB loaded at a
    > later point in time. In this precise case the controller of the
    > auxiliary NIB is instantiated from the Document NIB. So the easiest
    > thing to do would be to connect the controller and the
    > NSArrayController right within the Document NIB. But when I do so I
    > cannot have the NSArrayController "icon" in the auxiliary NIB. Thus
    > I need to bind manually.
    >
    > Actually I see one solution, but that seems a bit weird. I could
    > have a NSController objectin my NIB to act as a proxy to an
    > attribute of the controller. Actually, I did just that in HoudahSpot
    > 1.x
    >
    > Pierre
    >
    > ---
    > Pierre Bernard
    > http://www.bernard-web.com/pierre
    > http://www.houdah.com
    >
  • Good Point!

    Thanks Dave.

    Pierre

    On Dec 7, 2007, at 5:53 AM, David Spooner wrote:

    > Pierre,
    >
    > If your ArrayController is accessible as a property of the file's
    > owner, then in IB you can bind your TableView's content to the
    > file's owner using a model key path something like
    > 'arrayController.arrangedObjects' (and similarly for the
    > TableColumns...)
    >
    > Cheers,
    > dave
    >
    > On 6-Dec-07, at 3:39 PM, Pierre Bernard wrote:
    >
    >> Hi!
    >>
    >> I used to do this with Java NIBs on WebObjects, but never figured
    >> out how to do this in Cocoa.
    >>
    >> Imagine I have a NIB set up with an NSArrayController. Is there a
    >> way to create the NSArrayController before loading the NIB, having
    >> the dearchiving process skip the NSArrayController, connect and
    >> bind to the already existing instance.
    >>
    >> The concrete example I have run into today: I need to access an
    >> NSArrayController created in my Document NIB from a NIB loaded at a
    >> later point in time. In this precise case the controller of the
    >> auxiliary NIB is instantiated from the Document NIB. So the easiest
    >> thing to do would be to connect the controller and the
    >> NSArrayController right within the Document NIB. But when I do so I
    >> cannot have the NSArrayController "icon" in the auxiliary NIB. Thus
    >> I need to bind manually.
    >>
    >> Actually I see one solution, but that seems a bit weird. I could
    >> have a NSController objectin my NIB to act as a proxy to an
    >> attribute of the controller. Actually, I did just that in
    >> HoudahSpot 1.x
    >>
    >> Pierre
    >>
    >> ---
    >> Pierre Bernard
    >> http://www.bernard-web.com/pierre
    >> http://www.houdah.com
    >>
    >

    ---
    Pierre Bernard
    http://www.bernard-web.com/pierre
    http://www.houdah.com
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