• 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 10:57:52 -0500

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

No, don't do that!

Right now it seems like you're not storing up the data in memory
anywhere, and expecting NSTableView to keep track of it for you.
NSTableView doesn't work like that.  You have to explicitly tell it
what data goes in what row every time it asks you.  That's just how
the delegate methods work.

So, if you want to go the delegate route (your other choice is to use
Cocoa bindings), you'll need to keep track of all of the past samples
and what row they were in.  A simple way to do that might be to use an
NSMutableArray, and call -addObject: each time you get a new sample:

-(void) addSample:(id)sample
{
   // _dataArray is an instance of NSMutableArray
   [_dataArray addObject:sample];
}

-(int) numberOfRowsInTableView
{
   return [_dataArray count];
}

-(id) tableView:(NSTableView *)tableView objectValueForTableColumn:
(NSTableColumn *)Column row:(int)Row
{
   id theData = [_dataArray objectAtIndex:Row];
   // return the proper column of theData
}

This could be made much more efficient, especially for large datasets,
but that's the gist of it.

--
Stephen Deken
email@hidden
_______________________________________________
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:
    • 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