views:

290

answers:

1

I have a set of data where one of the attributes (Firmware) is a one-to-many relationship.

If I want to get any records where the firmware id is 1 I can create a predicate using

@"(ANY Firmware.FID==1)"

Then I have another set of conditions that will refine the set even more using

(TopLevel==YES) AND (Parent>0)

How can I combine them or set it up so that first it filters the firmware then it filters the second condition? Ultimately I want all of the records where Firmware.FID=1 and TopLevel==YES and Parent>0.

Thanks, Howie

+2  A: 

You should be able to use this predicate:

[NSPredicate predicateWithFormat:@"TopLevel == %@ AND Parent > %@ AND ANY Firmware.FID == %@",[NSNumber numberWithBool:YES],[NSNumber numberWithInteger:0],[NSNumber numberWithInteger:1]];  

I moved the condition on "ANY Firmware.FID" last since it is the most complex and it can be avoided if one of the other conditions has already failed.

gerry3
thanks for the help
Ward
If my answer helped, please accept it and consider an up-vote as well. Thanks.
gerry3