Hey Guys,
I'm trying to use NSPredicate to filter an array. Here's the structure of my
array

ArrayOfFoos:
    Foo: (Custom Object)
        Bars: (NSArray *)            Bar: (Custom Object)
                Baz = 1 (int Property on custom object)
            Bar:
                Baz = 3
        ...
    Foo:        Bars:
            Bar:
                Baz = 2
            Bar:
                Baz = 1
        ...
...

and
So what I want to do is pull out all Foos who have a baz == 1.

I've tried

NSPredicate *p = [NSPredicate predicateWithFormat:@"bars.baz == 1"];
NSMutableArray *ma = [NSMutableArray arrayWithArray:[arrayOfFoos
filteredArrayUsingPredicate:p]];

which obviously won't work because the bars don't have a baz property
because it's an array.

I've also tried adding [] so that it know it's an array, but that didn't
work either...

NSPredicate *p = [NSPredicate predicateWithFormat:@"bars[].baz == 1"];
NSMutableArray *ma = [NSMutableArray arrayWithArray:[arrayOfFoos
filteredArrayUsingPredicate:p]];

I'm not sure what expression to use to denote that I want the predicate to
drill down in to each bar to look for the baz.

I hope this make sense. Any help would be great.

Thanks,

:// Jake
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to