• 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: NSTableView with NSArray and C-array question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView with NSArray and C-array question


  • Subject: Re: NSTableView with NSArray and C-array question
  • From: "R. Matthew Emerson" <email@hidden>
  • Date: Fri, 13 Oct 2006 12:15:53 -0400


On Oct 13, 2006, at 11:43 AM, Gilles Celli wrote:


On Oct 13, 2006, at 5:39 PM, Glenn Zelniker wrote:


On Oct 13, 2006, at 11:34 AM, Gilles Celli wrote:

I'm assuming that you're trying to display in your table the data for a number of sensors (indicated by a column) at different points in time (indicated by row position). Is this correct?
yes right! In fact voltage values for a 16 channel multimeter. The NSTableView columns have numerical identifiers (1-16) and with Date/Time (but not implemented yet...).

Until you implement the Date/Time and map it to a row index, you're not going to see anything meaningful in your table.


GZ

so you think I that I should return a NSCalendarDate in method - (int)numberOfRowsInTableView... ?

No, that wouldn't do anything useful.

(Warning, code typed in mail.)

Say that you place each sample acquired from the digital multimeter into a C struct. (I seem to recall that you were asking about putting data stored in a C array into a table view, so I'll use vanilla C rather than objects.)

#include <sys/time.h>

struct sample {
struct timeval tv; /* via gettimeofday(2), for example, or use NSDate */
double channels[15];
};


struct sample samples[20000];	/* or dynamically allocate */
int nsamples;

Then your table view data source methods might look something like this:

- (int) numberOfRowsInTableView:(NSTableView *)tableView
{
    return nsamples;
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)Column row:(int)Row
{
struct sample s = samples[Row];


    if ([[Column identifier] isEqualToString:@"1"])
        return [NSNumber numberWithDoublle:s.channels[0]];
    else if ([[Column identifier] isEqualToString:@"2"])
        return [NSNumber numberWithDoublle:s.channels[1]];
    etc.

}

You could also put the timestamps in the table view by adding another column with an identifier of "timestamp", and formatting the struct timeval appropriately.


_______________________________________________ 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:
    • NSTimer question: How to fire at second 00, 05, 10 etc ?
      • From: Gilles Celli <email@hidden>
    • Re: NSTableView with NSArray and C-array question
      • From: Gilles Celli <email@hidden>
References: 
 >NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: "Mark Munz" <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Glenn Zelniker <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Glenn Zelniker <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Glenn Zelniker <email@hidden>)
 >Re: NSTableView with NSArray and C-array question (From: Gilles Celli <email@hidden>)

  • Prev by Date: Re: NSTableView with NSArray and C-array question
  • Next by Date: Re: NSTableView with NSArray and C-array question
  • Previous by thread: Re: NSTableView with NSArray and C-array question
  • Next by thread: Re: NSTableView with NSArray and C-array question
  • Index(es):
    • Date
    • Thread