On Wed, Mar 16, 2011 at 11:28 AM, Dave DeLong <davedel...@me.com> wrote:
> Directly, yes.  NSExpression stores a keypath as a single string, whereas 
> variables are store in their own kind of NSExpression object.  When you 
> replace variables with new values, it's only looking for the certain kinds of 
> NSExpression objects to replace.  Everything else stays the same.

Well that's a shame. That's also probably why [[NSPredicate
predicateWithFormat:@"SUBQUERY(events, $x, $x = $someVar)"]
predicateWithSubstitutionVariables:[NSDictionary
dictionaryWithObject:@"foo" forKey:@"someVar"]] doesn't work, either.
It skips over the subquery NSExpression.

>
> Some notes about your predicate:
>
> - I'm not sure you can do "$x isKindOfClass: %@" as the predicate to a 
> subquery, although I haven't tried it.

You can, but the syntax isn't documented. Then again, much of
NSPredicate is poorly documented.

>  If it doesn't work, you could do this with a FUNCTION ("FUNCTION($x, 
> 'ks_isKindOfClass:', %@)").  Note, however, that you'd have to create a 
> category on NSObject that simply boxes the return value of isKindOfClass into 
> an NSNumber.  FUNCTION()'s don't like methods that return primitives.

It seems to deal with BOOLs just fine; I believe it's internally
wrapping the value in an NSNumber, much like how arbitrary keypaths
are supported on 10.5 and up (they get wrapped in NSNumbers or
NSValues if necessary).

--Kyle Sluder
_______________________________________________

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 arch...@mail-archive.com

Reply via email to