discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView


From: Andreas Heppel
Subject: Re: NSTableView
Date: Fri, 06 Sep 2002 10:21:03 +0200

Hello Thierry,
this is quite simple. What you do have below is a dictionary of dictionaries. I 
guess you already know how to store this data in memory and how to access ist.
The object having access to this data (I will call it dataStorageObject)  will 
be the data source fpr your table view:
dataStorageObject = [[DataStorage alloc] init];
tableView = [[NSTableView alloc] initWithFrame: someRect];
// follows some initialisation stuf for the tableView
[tableView addTableColumn: statusColumn];
[tableView setDataSource: dataStorageObject];

The dataStorageObject's class must implement the following method, which is 
called _each_time_ the table view must redisplay itself. This method supplies 
the data to be displayed.

- (id) tableView: (NSTableView *) aTableView
       objectValueForTableColumn: (NSTableColumn *) aTableColumn
       row: (int) rowIndex
{
// here you must check the column and then return the appropriate data
   if (aTableColumn == statusColumn) {
       // retrieve the key's value from the dictionaries
       return [[outerDict objectForKey: rowIndex] objectForKey: @"Status"];
   }
}

You also must supply a method telling the table view its size (number of rows):

- (int) numberOfRowsInTableView: (NSTableView *) aTableView
{
 return [outerDict count];
}

I hope this gives you an idea about how to proceed. Good luck.

Cheers,
Andreas


On 2002-09-05 19:08:52 +0200 Thierry Leurent <address@hidden> wrote:

Hello,

I try to learn programming with GNUstep.
I have some trouble to understand exactly how to use NSTableView.
NSTableView is on a display object and I must use an other object to store the 
data.
I don't see how I can use an object to store the content of a file, like the 
sample at the end, and display it into a TableView.

Thanks

Thierry

{
     1 = {
        Key = "1";
        Status = "Unread";
        Attachment = "Yes";
        Subject = "Laetare 2002: Expo photos";
        From = "Newsletter Laetare.be";
        Date = "15 Apr 2002";
        Size = "12"
     };
     2 = {
        Key = "2";
        Status = "Unread";
        Attachment = "No";
        Subject = "Welcome! Bienvenue!";
        From = "Ludovic Marcotte";
        Date = "08 Apr 2002";
        Size = "2";
     };

}


_______________________________________________
Discuss-gnustep mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/discuss-gnustep


--

Andreas Heppel           SYSGO Real-Time Solutions GmbH     address@hidden
Software Engineering     Embedded and Real-Time Software    www.sysgo.de
Voice: +49-6136-9948-0   Am Pfaffenstein 14                 www.elinos.com
FAX:   +49-6136-9948-10  55270 Klein-Winternheim, Germany





reply via email to

[Prev in Thread] Current Thread [Next in Thread]