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: "Stephen Deken" <email@hidden>
- Date: Fri, 13 Oct 2006 11:17:03 -0500
and someone before wrote that there's too much overhead to add the
values to an NSArray (with more than 17000 rows...).
Yes, that's true. In that case you're better off keeping track of the
data in straight C structs to eliminate the overhead. You already
know the maximum number of rows you'll have, so you can preallocate
pointers, and then fill it up as you go. Code below was typed inline,
and was not run through any sort of checking.
--sjd;
struct my_data
{
float data_points[16];
} my_data;
struct my_array
{
my_data *data[1800];
int num_valid_rows;
} my_array;
@interface MyTableViewDelegate : NSObject
{
my_array my_array_instance;
}
@implementation MyTableViewDelegate
-(int) numberOfRowsInTableView:(id)v
{
return my_array_instance.num_valid_rows;
}
-(id) tableView:(id)t objectValueForTableColumn:...
{
// Add bounds and validity checks here!
return my_array_instance.data[row_num]->data_points[col_num];
}
_______________________________________________
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