Re: multiple nibs question
Re: multiple nibs question
- Subject: Re: multiple nibs question
- From: Eric Wang <email@hidden>
- Date: Fri, 15 Feb 2002 03:15:09 -0500
on 2/13/02 9:27 PM, email@hidden at email@hidden wrote:
>
Hello.
>
>
I am not the greatest expert in cocoa, but here is how I always do
>
things.
>
>
In the source nib (main nib) I create an outlet of type
>
NSWindowController. In the target nib I create a subclass of
>
NSWindowController. That subclass relays all the functionality that I
>
need.
>
>
On awakeFromNib I load the NSWindowController subclass and save the
>
reference into the outlet in the main nib file. In this way you get the
>
connection from main nib to target nib. After you have that, you can set
>
the reverse connection too, if you need it.
>
>
Example:
>
>
@interface A : NSObject
>
{
>
IBOutlet NSWindowController target;
>
}
>
@end
>
>
@implementation A
>
- (void) awakeFromNib
>
{
>
//there is no .nib below!!!
>
target = [[NSWindowController alloc]
>
initWithWindowNibName:@"myTargetNib"];
>
}
>
@end
>
>
@interface B : NSWindowController
>
@end
>
>
////
>
>
The outlet can be of type B, it is probably better in that way. You will
>
have to import the B.h file in A.h then. Or, if you have a dependency
>
problem you can use NSWindowController as outlet type, or use @class B
>
in A.h.
>
>
I bet my boots that there is a better, more scalable design out there.
>
Never bothered to read, since time is valuable :(. This works for me,
>
although I would love to see different opinions on this topic (with
>
examples please :)
>
>
GL.
>
>
Nick
Wouldn't your approach necessitate subclassing NSApplication (which is the
owner of the main nib file in my app) and adding the NSWindowController
outlet to the subclass? The Apple docs suggest against subclassing
NSApplication so I'm trying to avoid that.
Eric Wang
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.