Re: Newbie Q : communication problem with NSTableView
Re: Newbie Q : communication problem with NSTableView
- Subject: Re: Newbie Q : communication problem with NSTableView
- From: Wain <email@hidden>
- Date: Sun, 21 May 2006 08:45:53 +0100
On 21 May 2006, at 07:28, email@hidden wrote:
You say 'changes' so I'm guessing that the tableview is initially
populated with data OK and it's just not reflecting changes, right?
Actually the tableview is initially empty and it stays empty
(when it
shouldn't).
OK, ignore reloadData for now then, i'll assume next that your using
Interface Builder (IB) to create your window and tableview
and that you have setup the connections between your TableController
and the tableView there
This means that when your app starts and the nib is loaded the
tableview will automatically contact it's datasource to get data
So if the tableview is connected to it's datasource correctly it
should call numberOfRowsInTableView: as the first thing it does
you said originally:
I checked the following :
-connections (in both directions between the table view and the
instance of TableController)
-definitions of the tableView and numberOfRowsInTableView
functions in TableController.m
Is the TableController set as the tableviews datasource in IB, this
is the first place to look when you get no data displayed
Is numberOfRowsInTableView: called after your call to reloadData?
No. Should it ?
Yes, the tableview needs to check if any rows have been added or removed
Please tell me if I understood correctly : if tableView1 is to
display the contents of array1 and tableView2 is to display the
contents of array2, the code for numberOfRowsInTableView: would go as
follows :
-- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
if (aTableView==tableView1) {
return [array1 count];
}
if (aTableView==tableView2) {
return [array2 count];
}
}
What do you mean exactly by "tagging each tableview to id it" ?
All NSControl classes have a - (int)tag and - (void)setTag:(int)anInt
method, the tag can also be set in IB
the code above will work great, an alternative using tags looks
something like
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
if ([aTableView tag]==1) {
return [array1 count];
}
else if ([aTableView tag]==2) {
return [array2 count];
}
}
sorry no help out of the box but I need more info, which data source
methods have you implemented?
(int) numberOfRowsInTableView:,
(id)tableView:objectValueForTableColumn:row:
(id)tableView:setObjectValue:ForTableColumn:row:
Actually this last method is ``empty" ( I define it as
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
/*the table View is not editable */
}
you could try the tableview delegate method
tableView:shouldEditTableColumn:row: instead to prevent editing
)
because I do not want the table to be user-modifiable (although I
want the program to fill the table by itself).
Ewan
Wain
_______________________________________________
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