subclass of NSManagedObject not behaving as expected
subclass of NSManagedObject not behaving as expected
- Subject: subclass of NSManagedObject not behaving as expected
- From: Gonzalo Castro <email@hidden>
- Date: Fri, 20 Apr 2007 22:39:09 -0400
Hello,
I have an Employee entity with firstName and lastName attributes. In
the UI I have two text fields for entering a first name and last name
and an NSTableView where I want to display both in one column. I have
created a NSManagedObject subclass called EmployeeMO where I register
the dependent keys in the +initialize method.
[self setKeys:[NSArray arrayWithObjects:@"firstName",
@"lastName", nil]
triggerChangeNotificationsForDependentKey:@"fullName"];
My EmployeeMO.m subclass contains the methods found here:
http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueObserving/Concepts/DependentKeys.html
I've made the change in the object graph so Employee entity is of
class EmployeeMO.
There are two problems:
1. The full names in the NSTableView don't get updated when I tab out
of the first and last name NSTextFields. The NSTableView entries only
update to show the full names when I click on the table.
2. When I quit and relaunch the app only the first item in the
NSTableView displays the correct full name. The rest of the rows
where the other full names should be contain "(null) (null)".
If I don't use my EmployeeMO subclass and bind the NSTableView to
firstName, eg, I get the correct behavior. I suspect I should be
overriding something in EmployeeMO that I am not. I've read the
NSManagedObject doc and while it warns a lot about methods I
shouldn't override (which I'm not) there's no mention of any I must
override.
What am I missing?
Thanks,
Gonzalo
_______________________________________________
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