• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Populating a NSTableView. Almost There....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Supporting variable-number of table columns, based on source. (From: "Frederick C. Lee" <email@hidden>)
 >Re: Supporting variable-number of table columns, based on source. (From: Kay Roepke <email@hidden>)
 >Re: Supporting variable-number of table columns, based on source. (From: "Frederick C. Lee" <email@hidden>)
 >Re: Supporting variable-number of table columns, based on source. (From: Shawn Erickson <email@hidden>)
 >Populating a NSTableView. Almost There.... (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Populating a NSTableView. Almost There....
  • Next by Date: NSTimer not firing if date changed in Sys Prefs
  • Previous by thread: Populating a NSTableView. Almost There....
  • Next by thread: Re: Supporting variable-number of table columns, based on source.
  • Index(es):
    • Date
    • Thread