• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness


  • Subject: Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
  • From: Keary Suska <email@hidden>
  • Date: Fri, 17 Apr 2009 10:27:42 -0600


On Apr 16, 2009, at 9:01 PM, 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'".


I am not really up to speed on NSPredicateEditor, but could you use - ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow: to "convert" the display case of grade = A-F to a predicate that is actually grade >= <= score range? I imagine you would need to construct a compound predicate with subpredicates (sub-rows). Either that or use the "BETWEEN" operator.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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


  • Follow-Ups:
    • Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
      • From: Jerry Krinock <email@hidden>
References: 
 >Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Undo (UI Concept)
  • Next by Date: Re: starting point for screen-sharing
  • Previous by thread: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
  • Next by thread: Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
  • Index(es):
    • Date
    • Thread