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
jus...@secondgearsoftware.com
http://secondgearsoftware.com/
-
Check out FitnessTrack: meet your fitness goals with the iPhone <http://secondgearsoftware.com/fitnesstrack/
>
-
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com