Re: multiple nibs and table view
Re: multiple nibs and table view
- Subject: Re: multiple nibs and table view
- From: Stéphane Sudre <email@hidden>
- Date: Fri, 20 Jun 2003 18:53:50 +0200
On vendredi, juin 20, 2003, at 10:36 Europe/Paris, stephane wrote:
Hello,
[...]
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.
@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];
}
1) Set the File owner of your secondary nib to be tableViewController.
2) Set the Data Source and delegate of your NSTableView to be the File
owner, etc...
3) Don't use this:
tableViewController = [[NSWindowController alloc]
initWithWindow:tableViewWindow];
because:
i) it's wrong as tableViewController is a subclass of NSObject
ii) if you're initing it like this, no wonder there's no outlet set.
4) Do something like this instead:
if (tableViewController==nil)
{
tableViewController = [tableViewController alloc];
[NSBundle loadNibNamed:@"tableViewWindow" owner: tableViewController];
[tableViewWindow showWindow:self]; // Thought I'm wondering where
tableViewWindow is coming from...
}
Suggestions:
i) avoid using the same name for the instance and the class
ii) put a prefix on your class, e.g.: STTableViewController
_______________________________________________
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.