Communicating between controllers

Discussion in 'Mac Programming' started by hiddenpremise, Feb 3, 2009.

  1. macrumors regular


    Jul 25, 2008
    Somewhere between my imagination and reality
    I have two objects that I use two control the interfaces of two different windows in my application. Since ApplicationMagic takes care of creating instances of these controllers at start up, I am lost on how to refer to them. If I want to send one a message, how do I know what the name of the instance is?
    Thanks much,

    mainController : NSObject
    secondController : NSObject

    secondController contains a method "-(void) receive: (NSString *)pItem;"

    I want to call the instance of secondController that is created at startup from the mainController and send it an item "[nameIDontKnow receive:mad:"Hi"];"
  2. macrumors 601


    Jan 6, 2004
    Western US
    I don't know what ApplicationMagic is, but if they are in a nib/xib you can make and connect outlets, if created programmatically, you need to grab a reference to one and store it in the object you want to access it from. The mainController should probably be creating secondary controllers, so make a secondaryController variable in your main and assign it wherever you create it. If for some reason you can't do that (ApplicationMagic again?) you could maybe have the secondary send out a notification when it's initialized that the primary receives, passing itself for reference, where you assign it to your holder variable.

Share This Page