Core Data relationship fault
Can someone point me to an example or tutorial that shows how to get the value of a to-many relationship attribute of a Core Data entity? My application is simple and comparable to the Departments and Employees example in Apple's documents. When I select a department object I have no trouble accessing any of its other properties, but when I try to get its employees I get only a relationship fault. I have tried everything that I could find in the documentation and other people's comments (Google search) without success. I have subclassed the array controllers for departments and employees. In the departments array controller I am trying to calculate a transient property based on the properties of the employees when the method -(id)tableView:(NSTableView *)aTableView objectValueForTableColumn: (NSTableColumn *)aTableColumn row:(NSInteger)rowIndex is called by the departments TableView. Thanks. Lynn. ___ 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
Re: Core Data relationship fault
On 2011 Apr 11, at 09:54, Lynn Barton wrote: Can someone point me to an example or tutorial that shows how to get the value of a to-many relationship attribute of a Core Data entity? My application is simple and comparable to the Departments and Employees example in Apple's documents. You just answered you own question ;) When I select a department object I have no trouble accessing any of its other properties, but when I try to get its employees I get only a relationship fault. I am trying to calculate a transient property I'd bet that's the problem. In my experience, transient properties are all pain (lotsa gotchas) with no (performance) gain. Consider either making it a regular property, or, probably better for your case since a table view can only show several tens of rows at a time, calculating it as a derived attribute. For the latter, remember your friend +keyPathsForValuesAffectingFoo. ___ 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
Re: Core Data relationship fault
On Apr 11, 2011, at 11:48, Jerry Krinock wrote: On 2011 Apr 11, at 09:54, Lynn Barton wrote: When I select a department object I have no trouble accessing any of its other properties, but when I try to get its employees I get only a relationship fault. I am trying to calculate a transient property I'd bet that's the problem. In my experience, transient properties are all pain (lotsa gotchas) with no (performance) gain. Consider either making it a regular property, or, probably better for your case since a table view can only show several tens of rows at a time, calculating it as a derived attribute. For the latter, remember your friend +keyPathsForValuesAffectingFoo. Darn it, I was trying to stay out of this thread because I don't know the answer, but you made me jump in ... I feel for your pain, but I think there's a baby/bathwater issue with generalizing your experience. For things that really are transient, transient properties are very harmless, and don't need to be avoided. The differing points of view come from Core Data's dual personality. In its role as an object graph manager, the developer tends to be focused on in-memory relationships, and transient properties are useful. In its role as an (cough!) almost-DBMS (cough!), the developer tends to be focused on fetches, and that's where you run into the gotchas. Regarding the OP's question, my guess is that it's a memory management problem, and the object properties are faulted out because the objects themselves have been deleted from the MOC and/or deallocated. I have no evidence for that opinion. ___ 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
Re: Core Data relationship fault
Thanks, that helps. I need to study the Core Data Programming Guide again, and this time pay more attention to the FAQs. Lynn On 2011 Apr 11, at 09:54, Lynn Barton wrote: Can someone point me to an example or tutorial that shows how to get the value of a to-many relationship attribute of a Core Data entity? My application is simple and comparable to the Departments and Employees example in Apple's documents. You just answered you own question ;) When I select a department object I have no trouble accessing any of its other properties, but when I try to get its employees I get only a relationship fault. I am trying to calculate a transient property I'd bet that's the problem. In my experience, transient properties are all pain (lotsa gotchas) with no (performance) gain. Consider either making it a regular property, or, probably better for your case since a table view can only show several tens of rows at a time, calculating it as a derived attribute. For the latter, remember your friend +keyPathsForValuesAffectingFoo. ___ 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