• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Loading Nibs which are self-ref
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:36:33 -0400

 Well, I suppose that's what attracted me to this technique. When we call...

> 	secondWindow = [[SecondWindow alloc] init];

The init method within SecondWindow does this...

	self = [super initWithWindowNibName:@"SecondWindow" owner:self];

Meaning the Files Owner is SecondWindow -- because it was initialized that way.

Now, if common practice is to make the new nib in IB, then create a new NSObject instance within that nib and then subclass said instance to SecondWindow, I'm not sure what benefit initWithWindowNibName@"nameOfNib" owner:instantiatedObject would have in the real world.

It is interesting to note that subclassing FileOwer to SecondWindow actually does work. Outlets and Actions are seen and can be wired up in IB, forgiving any oddness I described which may or may not be odd at all.

Am I thinking too differently here?

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

References: 
 >Loading Nibs which are self-ref (From: Kevin Muldoon <email@hidden>)
 >Re: Loading Nibs which are self-ref (From: Wim Lewis <email@hidden>)
 >Re: Loading Nibs which are self-ref (From: Kevin Muldoon <email@hidden>)
 >Re: Loading Nibs which are self-ref (From: Jens Alfke <email@hidden>)
 >Re: Loading Nibs which are self-ref (From: Kevin Muldoon <email@hidden>)
 >Re: Loading Nibs which are self-ref (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: App Delegate Methods
  • Next by Date: Re: Loading Nibs which are self-ref
  • Previous by thread: Re: Loading Nibs which are self-ref
  • Next by thread: Re: Loading Nibs which are self-ref
  • Index(es):
    • Date
    • Thread