Update bound dictionary based on NSTextFieldCell’s edited value
Update bound dictionary based on NSTextFieldCell’s edited value
- Subject: Update bound dictionary based on NSTextFieldCell’s edited value
- From: Justin Williams <email@hidden>
- Date: Fri, 5 Jun 2009 08:44:58 -0500
I'm working on porting some ancient code (10.2 era) from NSCoding/
plist based archiving to using Core Data. I have an NSOutlineView with
a custom NSTextFieldCell. The outline view is bound to an
NSTreeController to provide the data.
The bindings model looks like this:
NSTreeController: Managed Object Context ->
Controller.managedObjectContext
NSOutlineView's NSTableColumn Value -> Tree
Controller:arrangedObjects:itemDictionary
The NSOutlineView has a custom NSTextFieldCell subclass that adds an
image next to the text field, so I am passing the NSManagedObject's
values to it as an NSMutableDictionary called itemDictionary so I can
pull and set the title and isChecked key values.
Where I am running into issues is updating the text field's value and
passing that changed value back to my managed object instance. After
the user double-clicks on the title value and edits it, it is passed
to -(id)objectValue, but I'm not sure what the next step is to get the
update propagated to my NSManagedObject instance. The code I have thus
far for reading and setting values in my NSTextFieldCell subclass is
below:
- (void)setStringValue:(NSString *)aString {
[super setObjectValue:aString];
}
- (void)setObjectValue:(id <NSCopying>)anObject {
id cellValues = anObject;
[super setObjectValue:[cellValues valueForKey:@"title"]];
[self setCheckState:[[cellValues valueForKey:@"isChecked"]
integerValue]];
}
- (id)objectValue {
return [super objectValue];
}
I think I'm on the right path in how to implement this the proper way,
but this last hurdle has my stuck. Anyone shed some light?
Thanks!
-
Justin Williams
email@hidden
http://secondgearsoftware.com/
-
Check out FitnessTrack: meet your fitness goals with the iPhone <http://secondgearsoftware.com/fitnesstrack/
>
-
_______________________________________________
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