My God that knowledge was hard won. Still, I'm getting some unresponsive behavior.

The usual way: You declare the button as an IBOutlet in SecondWindow’s instance variable declarations, and wire it up to the actual control in IB.

Yes, this works now that I have wired window to NSWindowController via inherited 'window' outlet and set delegate to controller. I just wasn't grokking. Partially because of this next question.

Can I (or should I) hook up File's Owner as I would a subclass of NSWindowController? Thereby skipping creating a new object- >subclassing as SecondWindow? That seems 'right'. That nicely separates my code from my UI, making it (bit) more portable, but may be contributing to unresponsive behavior.

For instance...This code will update NSTextField with text...

        secondWindow = [[SecondWindow alloc] init];
[secondWindow setStringValueOfMyTextField:@"Hello! I am SecondWindow! I am very glad to meet you."];
        [secondWindow showWindow:secondWindow];

This code will NOT update NSTextField with text...

        secondWindow = [[SecondWindow alloc] init];
        [secondWindow showWindow:secondWindow];
[secondWindow setStringValueOfMyTextField:@"Hello! I am SecondWindow! I am very glad to meet you."];
        
Thanks for the assistance. I'm looking forward to getting to the part which started me doing this part.




On Jul 7, 2011, at 12:17 PM, Jens Alfke wrote:


On Jul 7, 2011, at 5:03 AM, Kevin Muldoon wrote:


I don’t see a difference. Xcode is just a tool; it doesn’t dictate the ways you develop code. If anything, it’s the releases of the OS that introduce and deprecate ways of doing things.

And both NSWindowController and manual nib loading have been around forever.

1) So, how exactly is SecondWindow.m going to know about and act upon a NSButton or NSTextField within in the SecondWindow.xib?

The usual way: You declare the button as an IBOutlet in SecondWindow’s instance variable declarations, and wire it up to the actual control in IB.

2) Shouldn't [secondWindow close] be working just as [secondWindow window] is working?

Actually calling -window isn’t the right way to show the window. All it does is cause the window to be loaded; this may or may not cause the window to be visible depending on how you set the ‘visible at launch time’ flag on the window in IB. Usually you want this flag to be false so that NSWindowController can customize the window bounds (tiling or restoring) before it’s displayed. If you want to show the window, call -showWindow:.

For some reason, [secondWindow close] isn't working at all. At least the documentation says this is how it's done.

Hm. My first guess is that you didn’t wire up the window to the NSWindowController’s inherited ‘window’ outlet. Lots of things won’t work unless you do this. (You also have to wire up the window’s delegate to the controller.)

—Jens


Kevin Muldoon
e: caoimgh...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to