Reputation: 66
I am facing a weird problem, i have created a subclass of NSWindowController along with the xib (Swift). In the newly created xib (window)i have added two labels, two text fields and a button, outlets for the textfields have been created and an action is also been created for the button. When i run the code and click the button, the action is not getting called. I have checked the files owner and connections everything is fine and connected. Same thing i have done with Objective C, its working perfectly fine. I don't know what went wrong.
Upvotes: 0
Views: 782
Reputation: 214
I faced the same problem. I added a strong reference in the .h file to the sub window controller (aka NSWindowController
) declared in the main window controller and the problem is solved.
Put something like
@property (strong, nonatomic) AboutWindowController *aboutWindowController;
between @interface
and @end
in your header file.
Then in your implementation (.m) file, invoke your second window by:
self.aboutWindowController = [[AboutWindowController alloc] initWithWindowNibName:@"AboutWindow"];
[self.aboutWindowController showWindow:self];
Replace aboutWindowController
with your own controller's variable. Replace AboutWindowController
with your window controller subclass name.
You just need a strong reference from the main window for the second window to work properly.
Upvotes: 3