• 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
filling & sorting and NSTableView through bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

filling & sorting and NSTableView through bindings


  • Subject: filling & sorting and NSTableView through bindings
  • From: Koen van der Drift <email@hidden>
  • Date: Mon, 29 Jan 2007 19:23:34 -0500

Hi,

I recently switched to bindings to populate an NSTableView with the contents of an NSMutableArray through an NSArrayController. I am basing my code on the following tutorial from CocoaDevCentral: http:// www.cocoadevcentral.com/articles/000080.php. But in contrast to the mailbox tutorial, in my app the array is filled all at once after the user selects a certain action-button. However, nothing appears in the tableview, although I can see from the scrollbar that the array is being populated. Now when I click one of the column headers and then click on the action-button, I see all the items in the NSTableView as expected. If I then click on a column header to reverse the display in the table, all lines are empty again, until I click the again button (re-populating the array) which then indeed shows the items in reverse.

So after some more searching, I found a possible solution on mmalc's binding page, called "Batch import into an array, and other mass changes". Unfortunately so far I haven't been able to get this to work. That codes looks like this:

(void) addObjectsToEmployeesFromArray: (NSArray *)otherArray
{
if ([otherArray count] > 0)
{
NSRange range = NSMakeRange([self countOfEmployees], [otherArray count]);
NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange:range];


[self willChange:NSKeyValueChangeInsertion valuesAtIndexes: indexes forKey: @"employees"];
[[self employees] addObjectsFromArray:otherArray];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes: indexes forKey: @"employees"];
}
}


I can convert this to my own code, but what I am missing is where the key @"employees" comes from. Seems to me that the above snippet is part of a larger code chunk, which is where @"employees" is also used. How do I get this to work?

Second question, why doesn't the table automatically reverse it's display when I click on the column header and how can I fix that (ok, really 2 questions) ?

thanks,

- Koen.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: filling & sorting and NSTableView through bindings
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Re: Initializing Subclass of NSTextContainer
  • Next by Date: Re: WebView makes NSOpenGLView glitchy on MacBook
  • Previous by thread: Re: Initializing Subclass of NSTextContainer
  • Next by thread: Re: filling & sorting and NSTableView through bindings
  • Index(es):
    • Date
    • Thread