Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
- Subject: Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
- From: Mike Abdullah <email@hidden>
- Date: Sat, 18 Apr 2009 13:03:40 +0100
If it helps, the reason for Apple only supporting searching of
persistent properties is for performance. If you're using the SQLite
store for example, the predicate is not evaluated against the in-
memory objects, but against the individual bits of data in the SQLite
table. Of course, why Apple couldn't have then added automatic support
for in-memory matching as the second step I don't know…
On 17 Apr 2009, at 04:01, Jerry Krinock wrote:
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
_______________________________________________
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