Re: NSPredicate/NSExpression - can they solve this Core Data problem?
Re: NSPredicate/NSExpression - can they solve this Core Data problem?
- Subject: Re: NSPredicate/NSExpression - can they solve this Core Data problem?
- From: Dave DeLong <email@hidden>
- Date: Fri, 02 Apr 2010 10:46:48 -0600
I can't think of a way to do this without iterating over the entire array. It *might* be possible using key-value coding and fancy keypaths and whatnot, but iteration is going to be far simpler to implement and understand.
Dave
On Apr 2, 2010, at 8:27 AM, David Hoerl wrote:
> Objects:
> - NSManagedObject *item - some managaged object
> - NSArray *attributes - an array of the item's attributes
>
> Desired Result:
> - a possibly smaller array of attribites where [item valueForKey:<an attribute>] != nil.
>
> In code, I can simply iterate over the keys, perform the valueForKey, and skip nil values. I played around with expressions and predicates to solve this, to no avail.
>
> I completely understand that the code solution is probably the way to go - however, I'd be interested to know if a solution using NSArray's filteredArrayWithPredicate and/or some combination of predicates and expressions could provide the answer - as an academic exercise.
>
> David
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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