Re: File's Owner
Re: File's Owner
- Subject: Re: File's Owner
- From: Andy Lee <email@hidden>
- Date: Tue, 27 May 2008 13:36:58 -0400
On May 27, 2008, at 11:51 AM, Mike Abdullah wrote:
On 27 May 2008, at 15:06, Andy Lee wrote:
On May 27, 2008, at 9:52 AM, Kyle Sluder wrote:
On Tue, May 27, 2008 at 8:48 AM, Andy Lee <email@hidden> wrote:
I just noticed +loadNibNamed:owner: is actually in a category of
NSBundle
added by AppKit. So I'd amend the above as follows: -[NSObject
loadNibNamed:] would be added to NSObject by a category in
AppKit, and would
be documented on a page with a title like "Application Kit
Extensions".
Woah... so sending NSBundle a -loadNibNamed: message would make the
NSBundle the File's Owner of the NIB? Who would you send the
message
to? This seems like a bad idea.
You would send the message to the object you want to be the File's
Owner.
Instead of:
BOOL didLoad = [NSBundle loadNibNamed:@"MyNib" owner:myObject];
...you would say:
BOOL didLoad = [myObject loadNibNamed:@"MyNib"];
...thus leaving out any mention of bundles as an implementation
detail. It would then be correct to say that the File's Owner
would be the object that loaded the nib.
And then how would you know where to find the nib in question? :)
I guess I am reinforcing the argument that one needs code samples to
express oneself. :)
You can add -loadNibNamed: to NSObject yourself, right now:
- (BOOL)loadNibNamed:(NSString *)aNibName
{
return [NSBundle loadNibNamed:aNibName owner:self];
}
This would use the logic that +loadNibNamed:owner: uses for deciding
what bundle to look for the nib in (see the docs for the method). If
you want more control over what bundle is used, you could write an
NSObject method that wraps around -[NSBundle
loadNibFile:externalNameTable:withZone:]. I leave that as an exercise
for the reader.
--Andy
_______________________________________________
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