Re: multiple nibs and table view
Re: multiple nibs and table view
- Subject: Re: multiple nibs and table view
- From: Fritz Anderson <email@hidden>
- Date: Fri, 20 Jun 2003 12:54:05 -0500
I look at these lines in the MainController class
[NSBundle loadNibNamed:@"tableViewWindow" owner:self];
tableViewController = [[NSWindowController alloc]
initWithWindow:tableViewWindow];
in connection with the tableView outlet in the tableViewController
class.
I assume the tableView in question is instantiated inside
tableViewWindow.nib? It does not surprise me that the tableView outlet
is never initialized (is nil); nothing happens to initialize it.
The loadNibNamed:owner: message connects the tableView instance to the
MainController class. If appropriate, the owner's (MainController's)
awakeFromNib method will be called at the end of processing the
loadNibNamed:owner: message. But no processing or initialization will
occur in the tableViewController object, which in fact does not yet
exist.
After the loadNibNamed:owner: message, the tableViewController object
is created. But you do nothing (that I can see) to tell it about the
tableView. It is not the owner of the tableView's nib file. It is not
passed a pointer to the view. No initialization is done.
You may wish to consider making the outlet for the table a part of the
controller for the window in which it appears, and use
initWithWindowNibName:. That would allow you to clean up the layering
of controller objects, which I think may have misled you.
-- F
On Friday, June 20, 2003, at 03:36 AM, stephane wrote:
Now the issue is when I integrate this prototype into my application, I
can load the table view from the main menu nib but most of
functionalities are gone: I cannot delete records and set double click
action. I still can add records but the refresh method is working only
when I click on the row that will contain the new data! I notice in the
awake nib method that the table view value is "null" whereas in the
prototype this value is never null (see highlight below). No matter
what I tried to do, this value remains null. This lets me think that I
am missing something fundamental and haven't been able to find it out
till now.
So any help/hint/direction greatly appreciated (I have thoroughly read
all possible info I could find on lists and doc but none brought to
light...).
Here is some detail of the implementation
MainController.h
@class tableViewController;
@interface MainController : NSObject
...
--------
MainController.m
- (IBAction)openTableView:(id)sender
{
if (!tableViewController) {
[NSBundle loadNibNamed:@"tableViewWindow" owner:self];
tableViewController = [[NSWindowController alloc]
initWithWindow:tableViewWindow];
}
[tableViewController showWindow:self];
}
----------
tableViewController.h
#import <Cocoa/Cocoa.h>
#import <MainController.h>
@interface tableViewController : NSObject
{
IBOutlet id tableView;
}
- (void)awakeFromNib;
---------
tableViewController.m
- (void)awakeFromNib
{
...
[tableView setDoubleAction:@selector(myDoubleClick:)];
[tableView setTarget:self];
NSLog(@" %d ",tableView); //always returns null whereas in
prototype not
}
--
Fritz Anderson - Consulting Programmer - Chicago, IL
Mail: <email@hidden>
Risumi: <
http://resume.manoverboard.org>
_______________________________________________
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.