View Full Version : Communicating between controllers

Feb 3, 2009, 05:40 PM
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:@"Hi"];"

Feb 3, 2009, 06:54 PM
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.