Binding to NSTextField Cell not working, edited value resets to default

Posted by cygnus6320 on Stack Overflow See other posts from Stack Overflow or by cygnus6320
Published on 2010-03-30T21:16:26Z Indexed on 2010/03/31 20:23 UTC
Read the original article Hit count: 509

I'm working on a Core Data document application that dynamically creates NSTableColumns. The data cell type may be a checkbox, slider, etc. Programmatically binding to all cell types works, except for NSTextFieldCell.

All NSTextFieldCells fail to bind, and after editing they return to their default value. This happens no matter if they're binding to a string, a number (with an NSNumberFormatter applied), or a date (NSDateFormatter applied). I'm using the following format to do all bindings:

NSDictionary *textFieldOpts = [NSDictionary dictionaryWithObjectsAndKeys:@"YES", NSContinuouslyUpdatesValueBindingOption, @"YES", NSValidatesImmediatelyBindingOption, nil];
[aCell bind:@"value" toObject:[[entryAC arrangedObjects] objectAtIndex:0] withKeyPath:@"numberData" options:textFieldOpts];

Again, these statements work if the cell type is anything but an NSTextFieldCell.

I threw in an observeValueForKeyPath method to log when the value changes... and for other cell types (NSSliderCell for instance) I can see the value changing, but with the NSTextFieldCell, it never, ever updates.

Help!

© Stack Overflow or respective owner

Related posts about cocoa-bindings

Related posts about nstablecolumn