• 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
How do I refresh NSTableView after programmatically changing bindings on a dataCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I refresh NSTableView after programmatically changing bindings on a dataCell


  • Subject: How do I refresh NSTableView after programmatically changing bindings on a dataCell
  • From: François Beausoleil <email@hidden>
  • Date: Fri, 16 Jul 2010 23:16:59 -0400

Hi all,

I have an NSPopUpButton which holds the names of keys I want to display in an NSTableView. A picture is worth a thousand words: http://skitch.com/francoisb/dc63m/nstableview-redisplay

I have an action on my controller which rebinds the NSTableView's dataCell for the single column to a new value. Calling -[NSTableView reloadData] correctly refreshes the headerCell's title, but not the values. What should I be calling to ensure everything is refreshed?

I've searched Google with this email's subject, and while I found promising answers, I don't see what my specific problem is. I also read the "Troubleshooting Cocoa Bindings" from Apple's docs, but even with NSBindingDebugLogLevel set to 1, I don't see more messages.

Thanks!
François

Code below also at: http://gist.github.com/479199

NSTableView *documenstTable;

-(IBAction)changeDisplayedKey:(id)sender {
  NSString *newValue = [[sender selectedItem] title];
  NSTableColumn *column = [documentsTable tableColumnWithIdentifier:@"OID"];

  /* Replace title: works just fine */
  [[column headerCell] setStringValue:newValue];

  /* Bind to the new keyPath */
  /* data is an NSDictionary */
  NSString *newKeyPath = [@"arrangedObjects.data." stringByAppendingString:newValue];
  NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSRaisesForNotApplicableKeysBindingOption,
                          [NSNumber numberWithBool:YES], NSCreatesSortDescriptorBindingOption,
                          nil];
  [[column dataCell] bind:@"value"
                 toObject:documentsArrayController
              withKeyPath:newKeyPath
                  options:options];
  [documentsTable reloadData];
}_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: How do I refresh NSTableView after programmatically changing bindings on a dataCell
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: how to deploy the sqlite file in my Cocoa application installation
  • Next by Date: Re: Data downloading performance
  • Previous by thread: Matching a vcard with an address book record
  • Next by thread: Re: How do I refresh NSTableView after programmatically changing bindings on a dataCell
  • Index(es):
    • Date
    • Thread