I am trying to opening a window and assigning a controller with some data in it, without success.
I attach a brief source code.
The application is simply a main window with a button that opens a secondary window with a button. The secondary window has a controlling object called "ActionPanel".
The main window's button is connected to the ShowPanel action. It create the ActionPanel controller, initialize with the nib and prints for debug the "self" variable - that's what DebugMe does.
The second windows has a button connected to the same DebugMe method.
The application works as expected, but the ActionPanel object that receive the actions from the NIB is not the one I created.
The thing I am not able to understand is why the ActionPanel object changes between the ShowPanel instance and the one effectively connected with the nib.
This is the output I have in debug:
2010-04-23 11:26:59.032 Panels[4145:a0f] debug: I am <ActionPanel: 0x100212fe0>, target is <PanelsAppDelegate: 0x100137b80>
2010-04-23 11:26:59.856 Panels[4145:a0f] debug: I am <ActionPanel: 0x100165aa0>, target is (null)
The first line is the output of DebugMe called from the ShowPanel method, the second is print when I click on the second window's button.
I am sure I am missing something very trivial concept, can someone explain? Thank you in advance.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
- (IBAction) ShowPanel : (id) sender
ActionPanel *panel = [ [ ActionPanel alloc ] initWithWindowNibName: @"ActionPanel" owner: self ];