Re: Using NSPredicateEditor with core data
Re: Using NSPredicateEditor with core data
- Subject: Re: Using NSPredicateEditor with core data
- From: Gustavo Pizano <email@hidden>
- Date: Sat, 14 Aug 2010 08:43:56 +0200
Peter.
Thank you very much.
On Aug 14, 2010, at 12:27 AM, Peter Ammon wrote:
> You can get the left and right expressions, etc. by calling through to super:
>
> NSComparisonPredicate *superPredicate = [super predicateWithSubpredicates:subpredicates];
> NSExpression *lhs = [superPredicate leftExpression], *rhs = [superPredicate rightExpression];
> ...
>
> You would return a new predicate constructed from from the pieces of super's predicate, except substitute in your own modifier.
>
> -Peter
>
> On Aug 13, 2010, at 3:12 PM, Gustavo Pizano wrote:
>
>> Peter hello, first of all thanks for the reply.
>>
>> So yes, I need to cross a to-many relationship. let me see if I got this straight because my mind was heading in that same direction you commented, just I didn't know what to use or what was the name of the artifact, in this case the NSComparasionPredicateModifier.
>>
>> So due the fact that I already have overwritten NSPredicateEditorRowTemplate to enlarge the Floating-Decimal NSTextfield of the right expression, I would take that approach first, overwriden the predicateWithSubpredicates method and doing the following:
>>
>> - (NSPredicate *)predicateWithSubpredicates:(NSArray *)subpredicates{
>> NSPredicate * predicate = [NSComparasionPredicate predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression*)rhs modifier: NSAllPredicateModifier
>> type:(NSPredicateOperatorType)type options:NSCaseInsensitivePredicateOption];
>> }
>>
>> I don't know what lhs, rhs and type must be. should I pass [[self leftExpresions] objectAtIndex:0] and also for the rightExpresion? or does it comes from the subpredicates parameter?.
>>
>> sorry I got little confused there... :(
>>
>> Thx
>>
>> Gustavo
>>
>>
>> On Aug 13, 2010, at 11:49 PM, Peter Ammon wrote:
>>
>>>
>>> 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