Re: Newbie Q : communication problem with NSTableView
Re: Newbie Q : communication problem with NSTableView
- Subject: Re: Newbie Q : communication problem with NSTableView
- From: email@hidden
- Date: Sun, 21 May 2006 08:28:20 +0200 (CEST)
- Importance: Normal
>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).
>Is numberOfRowsInTableView: called after your call to reloadData?
No. Should it ?
>and when do you call reloadData?
as a newbie I tried to make something close to the example in
Hillegass' book (first edition). So I have a method "updateUI" in the class
MyDocument which contains all the various reloadData calls.
>All of the data source methods supply the requesting tableview, so
>your document could act as the datasource for all tableviews by
>tagging each tableview to id it, but it gets messy once you have a
>few table views.
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" ?
>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 */
}
)
because I do not want the table to be user-modifiable (although I
want the program to fill the table by itself).
Ewan
>
> Wain
> ------------------------------
>
> Message: 9
> Date: Sat, 20 May 2006 18:14:29 +0100
> From: Wain <email@hidden>
> Subject: Re: Newbie Q : communication problem with NSTableView
> To: Cocoa mailing list <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Hi,
>
> On 20 May 2006, at 18:02, email@hidden wrote:
>
>> Hello all,
>>
>> in a document-based project I have a NSTableView which it seems does
>> not receive the messages it should receive. Its data source is an
>> object called TableController containing an NSMutableArray called
>> arrayForTable, and the
>> table view should reflect the contents of arrayForTable.
>>
>> Now thanks to the debugger I know that arrayForTable behaves
>> correctly,
>> but the table
>> view does not display the changes.
>
> You say 'changes' so I'm guessing that the tableview is initially
> populated with data OK and it's just not reflecting changes, right?
>
>>
>> I tried to put a breakpoint on the crucial line
>>
>> [tableView reloadData];
>>
>> but unfortunately the debugger won't ``step into" that instruction,
>> so I'm
>> stuck...
>
> Is numberOfRowsInTableView: called after your call to reloadData?
>
> and when do you call reloadData?
>
>>
>> Most probably I made a beginner's mistake. 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
>>
>> (NB : I use the separate controller ``TableController" instead of
>> putting
>> everything into the MyDocument class, because there are several
>> tableviews on the same window,so MyDocument cannot be a dataSource for
>> all of them at the same time)
>
> All of the data source methods supply the requesting tableview, so
> your document could act as the datasource for all tableviews by
> tagging each tableview to id it, but it gets messy once you have a
> few table views.
>
>>
>> Ewan
>
> sorry no help out of the box but I need more info, which data source
> methods have you implemented?
>
> 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