Re: Using NSPredicateEditor with core data
Re: Using NSPredicateEditor with core data
- Subject: Re: Using NSPredicateEditor with core data
- From: Peter Ammon <email@hidden>
- Date: Fri, 13 Aug 2010 14:49:16 -0700
On Aug 13, 2010, at 8:45 AM, Gustavo Pizano wrote:
> Hello all once again.
>
> I have been searching but I hadn't found something useful, so please before if you know a place I can look at let me know.
>
> I have these 3 Entities
>
> ExpenditureGroup:
> name
> icon.
> -----------------------
> toExpenditures. ->>
>
>
> Expenditure
> creationDate
> location
> total
> --------------------
> toExpenditureGroup ->
> toExpenditureDetails ->>
>
>
> ExpenditureDetail
> detailDescrb
> subTotal
> ----------------------
> toExpenditure ->
>
> also I have an arrayController that fetches all the ExpenditureGroup Entities called _expenditureGorupArrayController.
>
> in my predicate editor I added the NSPredicateEditorRowTemplates with key paths for toExpenditures.location, toExpenditures.creationDate, toExpenditures.total, toExpenditures.toExpenditrueDetails.detailDescrb and finally toExpenditures.toExpenditureDetails.subTotal.
>
> I dunno if those last 2 are ok.. my guess NO.
>
> anyway, when I set the predicate, Im setting into the _expenditureGroupArrayController setFilterPredicate, and pass the predicate I just created, but nothing seems to work.
Hi Gustavo,
It looks like you want your predicate to cross a "to-many" relation. Is that right? If so, you need to create a predicate that has an NSComparisonPredicateModifier that knows how to cross to-many relations (that is, either NSAllPredicateModifier or NSAnyPredicateModifier).
If you're using NSPredicateEditor to create the predicate, then the RowTemplate has to know to create a predicate with the right modifier. Unfortunately you cannot yet set that up in IB, but you can do it programmatically, by passing the right NSComparisonPredicateModifier to one of the initWith... methods on NSPredicateEditorRowTemplate (see its header).
You can also subclass NSPredicateEditorRowTemplate and override -predicateWithSubpredicates: to create an NSPredicate with the proper modifier.
Hope that helps, let me know if that's not clear,
-Peter
_______________________________________________
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