• 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: "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


References: 
 >NSTableView with NSArray and C-array question (From: Gilles Celli <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>)
 >Re: NSTableView with NSArray and C-array question (From: "Stephen Deken" <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: subclassing WebView
  • 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