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 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