Re: Populating a NSTableView. Almost There....
Re: Populating a NSTableView. Almost There....
- Subject: Re: Populating a NSTableView. Almost There....
- From: Justin Spahr-Summers <email@hidden>
- Date: Wed, 30 Mar 2005 22:29:11 -0600
Returning an NSDictionary won't set the values in the table. You need
to pull the corresponding column in the dictionary from the
'aTableColumn' argument and return the value of that.
On Wed, 30 Mar 2005 20:14:45 -0800, Frederick C. Lee
<email@hidden> wrote:
> Greetings:
> I've created the data source {an array of dictionaries) and added the
> NSTableColumns and connected the NSTableView with the data source.
> Each NSTableColumn's identifier is the same as the column header/title
> and matches the keys of the NSMutableDictonarys within the
> NSMutableArray data source. But what I get are columns of '{'s (one
> per cell).
>
> Scenario:
> I've create an Array of Dictionaries, each dictionary contains values
> per each column per row (there are over 3900 rows).
> The column headers/identifiers match their respective keys of the
> NSMutableDictionary.
>
> (gdb) po [DBFArray objectAtIndex:0] <-- one of 3900+ rows.
> <NSCFDictionary 0x252efd0>{
> cat = 78;
> f_code = "FA001";
> fibs = "FP";
> gid = 41507;
> male = 137582;
> total = 266339;
> female = 128757;
> ratio = 106.900000000000006;
> name = "French Polynesia";
> }
>
> The table should look like this:
> cat | f_cde | fibs | gid | male | total | female | ratio | name | <--
> column header (identifiers)
> ... data ...
>
> -------------------------------
> ...
> ...
> [attrTableView setDataSource:DBFArray];
> ...
> ...
>
> ------------------------------
>
> @implementation NSArray (NSTableDataSource)
>
> // 1) Just returns the number of items we have.
> - (int)numberOfRowsInTableView:(NSTableView *)aTableView {
> return [self count]; // 'self'
> refers to DBFArray.
> }
>
> //
> ------------------------------------------------------------------------
> ----------------
> // 2) Display Items:
> - (id)tableView:(NSTableView *) aTableView
> objectValueForTableColumn:(NSTableColumn *) aTableColumn row:(int)
> rowIndex {
> return [self objectAtIndex:rowIndex]; // 'self' refers to DBFArray.
> }
>
> @end
>
> ------------------------------------------------------------------------
> ------------------
> Here's what #2) above would return:
>
> (gdb) po [self objectAtIndex:rowIndex]
> <NSCFDictionary 0x252efd0>{
> cat = 78;
> f_code = "FA001";
> fibs = "FP";
> gid = 41507;
> male = 137582;
> total = 266339;
> female = 128757;
> ratio = 106.900000000000006;
> name = "French Polynesia";
> }
>
> ===============
>
> All I get are columns of '{'.
>
> What am I missing???
>
> Regards,
> Ric.
_______________________________________________
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