Re: Presetting instance variables when nib-loading
Re: Presetting instance variables when nib-loading
- Subject: Re: Presetting instance variables when nib-loading
- From: Ondra Cada <email@hidden>
- Date: Fri, 26 Mar 2004 17:56:40 +0100
On Friday, Mar 26, 2004, at 17:14 Europe/Prague, Jerry LeVan wrote:
Alternatively, is there any way to prevent -awakeFromNib from being
called on the controller being awoken as the File Owner in a secondary
nib? The idea here is to prevent -awakeFromNib from being executed
more
than once, without having to implement an entire separate controller
class for the one outlet and one method the sheet I'm loading needs. I
could put the sheet in the main nib, but Apple keeps telling us not to
put more than one window into one nib. Thoughts?
Could you increment an instance variable when awakeFromNib is invoked.
Since the variables are initialized with zero you could tell if
awakeFromNib had already been invoked...
Far as I understand the original question (which I must have missed
before) properly
(a) you don't want to "prevent -awakeFromNib from being executed more
than once", for, at least generally, *each* NIB loading might need its
own set up;
(b) though, preventing inappropriate code to be executed should be even
more simple -- just use any outlet, linked to an object in the second
NIB:
@interface Controller:NSObject {
...
IBOutlet id filledFromTheSECONDNib;
...
@end
@implementation Controller
...
-(void)awakeFromNib {
if (!filledFromTheSECONDNib) { // first NIB has just been loaded in
...
} else { // second NIB has just been loaded in
...
}
}
...
Note: presumed the application is comparatively plain, feel free to put
the sheet (or whatever else) into the main NIB. You can split it
later--if needed at all--when you are more familiar with the Cocoa ways.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.