Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
- Subject: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
- From: Jerry Krinock <email@hidden>
- Date: Thu, 16 Apr 2009 20:01:23 -0700
The fact that Core Data "cannot fetch using a predicate based on
transient properties" [1] seems to greatly limit the utility of the
NSPredicateEditor view, and makes me very sad.
For example, say that my objects are student test results with a
'score' attribute and two dozen other properties. I could give the
user an NSPredicateEditor and let them have oodles of fun constructing
complex predicates.
But what if I need the user to be able to set a predicate with a left-
side-expression of "letter grade" and a right-side-expression popup
menu showing 'A' - 'F'. If I could fetch based on a transient
'letterGrade' attribute, I could implement some custom accessors which
would calculate 'letterGrade' from 'score' as needed, the predicate
emitted from the NSPredicateEditor would "just work", and life would
be sweet.
But since I can't use transient properties in my predicate, providing
a popup like that in NSPredicateEditor seems to mean that I'm going to
have to somehow deconstruct the compound predicate which Apple put so
many man-years of engineering into, have Core Data do "sub-fetches",
then do my own filtering and put the results back together. I fear
that writing bug-free code to handle the general compound predicate
would be very time-consuming, and also it would be MVC hell with my
NSPredicateEditor subclass (view) code wanting to have model logic
such as "if score > 93, letterGrade = 'A'".
Does anyone have any suggestions for a "least worst" workaround?
Thanks,
Jerry
[1] http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html#/
/apple_ref/doc/uid/TP40002484
_______________________________________________
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