Re: NSTableView with NSArray and C-array question
Re: NSTableView with NSArray and C-array question
- Subject: Re: NSTableView with NSArray and C-array question
- From: Gilles Celli <email@hidden>
- Date: Fri, 13 Oct 2006 17:10:19 +0200
I've figured out how to display only the C-array in NSTableView,
however i've getting for every Row the same value, e.g for 3 rows and
1 channel:
(remember updates every 5 seconds via reloadData the NSTableView)
Channel1
-4.555
-4.555 => from previous row :-(
-4.555 => from previous row :-(
For method numberOfRowsInTableView I've only a counter which gets
incremented after every reloadData.
- (int) numberOfRowsInTableView:(NSTableView *)tableView
{
return counter;
}
Any help / suggestion ?
Thanks
Gilles Celli
On Oct 12, 2006, at 6:41 PM, Mark Munz wrote:
Unless you are using bindings, NSTableView doesn't need an NSArray. It
is often just convenient to use them because you're often times
displaying a collection of NSObjects (such as NSString or NSNumber).
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex;
Neither of these reference any NSArray. the objectValueForTableColumn
does require an object be returned, but that could be supplied with
something like [NSString stringWithFormat:@"%f",myArray[rowIndex]];
There is nothing that stops you from using standard C-arrays. It
sounds like doing so would dramatically reduce overhead (otherwise you
have to create an NSNumber object for each value you want to add to
the NSArray, which only deals with NSObjects).
Mark Munz
On 10/12/06, Gilles Celli <email@hidden> wrote:
Hello everyone,
My first post here, I hope it fits in this list...
I'm porting a C-based data acquistion program running in Mac OS X
Terminal.app to Cocoa.
The C-based data acq. program scans 16 channels from a Keithley 2700
(with 7700 multiplexer) Multimeter every 5 seconds via USB-to-Serial
Port.
The multimeter spits out a string which then I convert to 'double'
float values in a C-array. This works great since a couple of months.
The main part of it, acquiring data every 5 sec works fine also in
Cocoa (using NSTimer etc.)
However displaying the data with NSTableView gives me more
headaches...
[1]. Should I use only *one* NSMutableArray or *multiple*
NSMutableArray for the channels ?
My understanding is that NSTableView needs an NSArray to display the
data row-wise, so I can't use the C-array directly....
(Since the array grows up every 5 seconds....(so for one day we get
about: 86400sec / 5sec = 17280 lines).
So for 16 channels: (16*17280) = 276480 data values for a full
day...this will make a really big array, IMHO.)
[2]. How to simplify the output of data with method (id)tableView:
(NSTableView *)tableView objectValueForTableColumn....?
I've tried using this for the 16 columns:
if ( [[Column identifier] isEqualToString:@"1"])
{
return [array objectAtIndex:Row];
}
etc.
This works less or more but every row gets the same value as the row
before!!! It drives me nuts!
Does someone have any suggestions with [array valueForKey....] ?
Any suggestions will be greatly appreciated.
--
Mark Munz
unmarked software
http://www.unmarked.com/
_______________________________________________
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