Re: Problem with a framework with a nib
Re: Problem with a framework with a nib
- Subject: Re: Problem with a framework with a nib
- From: Kyle Hammond <email@hidden>
- Date: Sun, 20 Feb 2005 09:24:19 -0600
Hi,
Whether a nib is in a framework or not is irrelevant to it working.
There's most likely some problem with either
1. the way you are initializing the window controller, or
2. the way you have the controller hooked up in IB.
For the answer to 1, here's how I coded a window controller that's in a
framework along with it's nib (class and nib file names changed to
protect the innocent or myself).
@implementation MyFrameworkedWindowController
- (id)init
{
NSString *path;
path = [ [ NSBundle bundleForClass:[ self class ] ]
pathForResource:@"MyNibName"
ofType:@"nib" ];
NSAssert( nil != path, @"Could not find MyNibName.nib file" );
return [ super initWithWindowNibPath:path owner:self ];
}
// ... other normal window controller code like -windowDidLoad, action
methods, etc omitted
@end
Then any code (whether it's in the framework or not), can allocate and
call -init on the window controller and it loads up it's nib just fine.
Note that I make sure I could find the nib file with an NSAssert since
it's always possible for some malicious (or just dumb) user to delete
things inside the framework. With the NSAssert, at least the app
doesn't crash and there's a line in the Console log file explaining
what happened.
For the answer to 2, in MyNibName.nib file I set the File's Owner to be
of class MyFrameworkedWindowController. Then I hook up the
outlets/actions of Files Owner to the relevant user interface bits in
the window. Works like a charm. Make sure you hook up the "window"
outlet of the Files Owner to the window you want to control, otherwise
NSWindowController subclasses don't work very well.
Enjoy,
Kyle
I'm writing a framework that has a nib file. Now I've chosen to
make
the controller for the interface a window controller however it
appears that it cannot connect to any part of the windows. I have a
window called progressWindow and one called resultWindow. calling
makeKeyAndOrderFront results in nothing happening. The window's don't
appear. If I choose to make one of the windows the window
controller's "window" then I can get it to appear with [[self window]
makeKeyAndOrderFront:self]. But the progress indicator, the text
field all of the other items in the window are dead as thursday
night. I cannot control them. I can't make the indicator
indeterminate or determinate... Does any one know what I need to do
to make it work? Would it be better to make the interface part of the
framework an nsobject and use initWithNibName:@"theNib" ? Or is it
just that frameworks can't have working interface objects?
---------------------
Kyle Hammond
email@hidden
<http://www.snowmintcs.com/> - personal productivity software
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden