Re: Loading Nibs which are self-ref
Re: Loading Nibs which are self-ref
- Subject: Re: Loading Nibs which are self-ref
- From: Kevin Muldoon <email@hidden>
- Date: Thu, 07 Jul 2011 18:50:47 -0400
Ahh. Yes. I see what you're saying. And maybe you see where I was confused. This GUI approach to hooking up code/UI is nifty, but extremely difficult to explain/comprehend.
As to xCode2,xCode3,xCode4, you'll notice one of the first things we used to have to do was create an AppController, then create an NSObject in IB and then make it a subclass of AppController and then hook it as a delegate of File Owner. That was annoying, and in later additions of xCode, the AppDelegate is automagically created and xCode encouraged developers to access UI elements via separate Controller objects.
This makes sense and I wanted to do just that, but you'll notice nobody ever mentions subclassing the File's Owner of SecondWindow.nib to the SecondWindow.m the window is supposed to be controlled by.
As if to say this would be explaining how exactly to breathe.
On Jul 7, 2011, at 5:36 PM, Jens Alfke wrote:
>
> On Jul 7, 2011, at 12:45 PM, Kevin Muldoon wrote:
>
>> 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.
>
> I’m sorry, I don’t understand what you’re asking. The class of the Files’ Owner object should be set to your NSWindowController subclass. You don’t add any custom object to the nib for the window controller.
>
> The “File’s Owner” pseudo-object in the nib is a placeholder for the pre-existing object specified as the owner when the nib is loaded; it’s not an object loaded by the nib. The purpose of that object is so that outlets in that object can be hooked up, and so objects from the nib can be pointed at it.
>
>> 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.”;
>
> Both of those should work correctly.
>
> —Jens
Kevin Muldoon
e: email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden