2
votes

I have simple non document, cocoa app in which I have added new NSWindowController, named Login and I created a .xib file for it. I want this window to be opened first when the app is started.

I have changed the main interface section to my project from MainMenu to Login, and when I run the app, indeed the new login window is started first.

However...none of the outlets work. I get error message for each outlet in my login window that looks like this:

Failed to connect (userNameTextField) outlet from (NSApplication) to (NSTextField): missing setter or instance variable

What I am doing wrong?

1

1 Answers

1
votes

I encountered the same error message. The solution in my case may not be directly applicable but perhaps it will help in some way.

I created a TestWindow view controller with associated xib and set up some referencing outlets. I then programmatically created the window with NSWindowController* window = [[NSWindowController alloc] initWithWindowNibName:@"TestWindow"]; and got the same sort of error message. I finally realized that I should write [TestWindow alloc] instead of [NSWindowController alloc] and that fixed everything. It seems so obvious in retrospect but I'm still getting used to what Interface Builder does and doesn't do for you auto-magically.

Your error message says it can't connect from (NSApplication) instead of (YourAppClassName), so I suspect the class that you define your outlets in isn't actually being instantiated.