Communicate two window controllers.

  • Hi again. I'm having some problem here.
    I have two windows A and B.
    > From A I call B as a sheet, but as B has lot of controls and
    operations, I decided to put everything in a separate controller.
    When I'm finished with B, I want to obtain some values that I have
    stored in B controller.
    As they are only 3 strings I know I can put them on textboxes or
    labels that are hidden and then read them from the A controller, but
    this is...dirty
    Is there anyway to access the B controller directly?

    And again we fall.
  • Am 24.09.2007 um 00:44 Uhr schrieb Jere Gmail:

    > Is there anyway to access the B controller directly?

    Yes. You store a reference to B someplace where you can reach it from A.

    Exactly *where* depends on the case at hand.

    If B is somehow dependent on A, you might want to store the reference
    If both windows are largely unrelated, you could store it in the
    application delegate.

    An object that is always accessible in a Cocoa application, is the
    application object itself:
    [NSApplication sharedApplication]  or  NSApp  which is a shortcut for

    Almost all Cocoa applications have a delegate which, in turn, you get
    [NSApp delegate]

    This is an excellent place to keep track of application global objects.

    Thus you'd get the B controller using  [[NSApp delegate]
    bController]  from anywhere inside your application.

previous month september 2007 next month
          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
Go to today