• 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
Populating a NSTableView. Almost There....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Populating a NSTableView. Almost There....


  • Subject: Populating a NSTableView. Almost There....
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Wed, 30 Mar 2005 20:14:45 -0800

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.


On Mar 29, 2005, at 11:23 AM, Shawn Erickson wrote:


On Mar 29, 2005, at 11:15 AM, Frederick C. Lee wrote:

I'm a little lost about mapping the new table columns to the source columns (beyond pre-defined iVars in a data model).

NSDictionary per row with key holding a column tag and value the value for that row and column and put those in an NSArray bind with an controller... etc.


-Shawn



_______________________________________________ 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
  • Follow-Ups:
    • Re: Populating a NSTableView. Almost There....
      • From: Justin Spahr-Summers <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>)

  • Prev by Date: Re: trouble getting c-chars from NSString
  • Next by Date: Re: Populating a NSTableView. Almost There....
  • Previous by thread: Re: Supporting variable-number of table columns, based on source.
  • Next by thread: Re: Populating a NSTableView. Almost There....
  • Index(es):
    • Date
    • Thread