Re: NSPredicate: Using NSExpression CAST(x, 'Class') is deprecated and will be removed in a future release

2022-03-16 Thread Sean McBride via Cocoa-dev
On 18 Nov 2021, at 19:44, Sean McBride via Cocoa-dev wrote: > Hi all, > > Starting in Monterey, I see a new message logged by Core Data during > persistent store migration: > > NSPredicate: Using NSExpression CAST(x,'Class') is deprecated and will be > removed in a future

NSPredicate: Using NSExpression CAST(x, 'Class') is deprecated and will be removed in a future release

2021-11-18 Thread Sean McBride via Cocoa-dev
Hi all, Starting in Monterey, I see a new message logged by Core Data during persistent store migration: NSPredicate: Using NSExpression CAST(x,'Class') is deprecated and will be removed in a future release. 'MyClassName' should not be cast into a Class object.' This is due to my .xcmapping

Where's NSExpression format string syntax documented?

2014-12-12 Thread Jens Alfke
I'm looking for a description of the expression syntax that +[NSExpression expressionWithFormat:] parses, but I can't find anything. There's a whole page on the _predicate_ format string syntax*, but that only covers the syntax specific to predicates and ignores expressions. (For example

Creating an NSExpression with a keypath and variable

2011-03-16 Thread Kyle Sluder
Hi all, Is it really impossible to create an NSExpression of the form $variableName.someKeyPath? I can create an NSExpression for $variableName, and I can create an NSExpression for someKeyPath, but I can't create one that contains both. The actual problem is that I'm trying to create

Re: Creating an NSExpression with a keypath and variable

2011-03-16 Thread Dave DeLong
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. Some

Re: Creating an NSExpression with a keypath and variable

2011-03-16 Thread Dave DeLong
On Mar 16, 2011, at 11:28 AM, Dave DeLong wrote: - If you want to use a keypath with a variable, you could do: FUNCTION($x, 'text') CONTAINS[cd] $searchString Or put another way: FUNCTION($x, 'valueForKeyPath:', 'foo.bar.baz') Dave ___

Re: Creating an NSExpression with a keypath and variable

2011-03-16 Thread Kyle Sluder
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

Re: NSExpression is incorrect?

2010-11-22 Thread Dave DeLong
Thanks for this suggestion, Ben. I ultimately went with a combination of this suggestion (dynamically determining associativity) and Ronald's suggestion (allowing the user to choose). My parser will start with the associativity used by NSExpression, but provides a property to change

Re: NSExpression is incorrect?

2010-11-21 Thread Ben Haller
Another option would be to make your code mimic whatever NSExpression is doing on that machine, by evaluating 2 ** 3 ** 2 (once, and caching the result) and seeing whether it comes out as 64 or 512. That way if/when Apple fixes their bug, your code will seamlessly follow suit. Which

NSExpression is incorrect?

2010-11-20 Thread Dave DeLong
Hi everyone, Let's say I have the string @2 ** 3 ** 2. I can run this through NSPredicate to parse it into an NSExpression tree for me, like so: NSExpression * e = [(NSComparisonPredicate *)[NSPredicate predicateWithFormat:@2 ** 3 ** 2 == 0] leftExpression]; When I log/evaluate

Re: NSExpression is incorrect?

2010-11-20 Thread Roland King
this through NSPredicate to parse it into an NSExpression tree for me, like so: NSExpression * e = [(NSComparisonPredicate *)[NSPredicate predicateWithFormat:@2 ** 3 ** 2 == 0] leftExpression]; When I log/evaluate this predicate, it gives me (2 ** 3) ** 2, which evaluates to 64. In other

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-03 Thread Ben Trumbull
2, 2010, at 3:42 PM, Ben Trumbull wrote: NSComparisonPredicate* exprPred = (NSComparisonPredicate*)[NSPredicate predicateWithFormat:@SUBQUERY(self, $key, %...@.$key != nil) == 0, obj]; NSExpression* expr = [exprPred leftExpression]; NSLog(@expression subquery results

NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread David Hoerl
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,

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread Dave DeLong
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: -

re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread Ben Trumbull
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

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread David Hoerl
against this target (think a NSExpression using a keyPath], and the result is a smaller array. I suspect it can be done but have not figured out how to do it yet. The stumbling block is that the target for most expressions will be the keys, one at a time, where it would be best if instead

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread Ben Trumbull
]; NSLog(@filtered array results = %@, [keys filteredArrayUsingPredicate:pred]); NSComparisonPredicate* exprPred = (NSComparisonPredicate*)[NSPredicate predicateWithFormat:@SUBQUERY(self, $key, %...@.$key != nil) == 0, obj]; NSExpression* expr = [exprPred leftExpression

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread Dave DeLong
predicateWithFormat:@SUBQUERY(self, $key, %...@.$key != nil) == 0, obj]; NSExpression* expr = [exprPred leftExpression]; NSLog(@expression subquery results = %@, [expr expressionValueWithObject:keys context:nil]); smime.p7s Description: S/MIME cryptographic signature

Re: Core Data and +[NSExpression expressionForFunction:...]

2009-11-29 Thread Ron Aldrich
I'm left wondering Under what circumstances would +[NSExpression expressionForFunction:selectorName:arguments:] be useful. An example would be helpful, but I sure wasn't able to find one. Meanwhile, I switched to a simple bounds check, which works just fine. Thanks for your time. - Ron

Re: Core Data and +[NSExpression expressionForFunction:...]

2009-11-27 Thread Ron Aldrich
: (NSNumber*) inLatitude longitude: (NSNumber*) inLongitude { NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression expressionForEvaluatedObject] selectorName: @distanceFromLatitude:longitude

Re: Core Data and +[NSExpression expressionForFunction:...]

2009-11-27 Thread Jerry Krinock
On 2009 Nov 27, at 12:23, Ron Aldrich wrote: but I'd very much like to understand why this isn't working. On Nov 25, 2009, at 11:34 PM, Alexander Spohr wrote: I am not sure if that works at all. I never fetched using methods that are not part of the database as a qualifier. The reason

Core Data and +[NSExpression expressionForFunction:...]

2009-11-25 Thread Ron Aldrich
longitude: (NSNumber*) inLongitude { NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression expressionForEvaluatedObject] selectorName: @distanceFromLatitude:longitude: arguments

Re: Core Data and +[NSExpression expressionForFunction:...]

2009-11-25 Thread Alexander Spohr
geoLocation information for all of the objects of type Photo which are within a specified distance of a target point, using the following code. - (NSArray*) photosNearLatitude: (NSNumber*) inLatitude longitude: (NSNumber*) inLongitude { NSExpression *theLHS = [NSExpression

NSExpression with constant NSData value crashes Core Data

2009-05-22 Thread Jerry Krinock
code with using -[NSComparisonPredicate predicateWithLeftExpression:rightExpression:modifier:type:options:]. I used -[NSExpression expressionWithConstantValue:] to create the expressions. The left expression value was the name of an attribute which is of type Binary Data, and the right

re: NSExpression with constant NSData value crashes Core Data

2009-05-22 Thread Ben Trumbull
On 2009 May 17, at 15:10, Ben Trumbull wrote: Core Data supports == and != searches against binary data. You should be able to just use a predicate like: [NSPredicate predicateWithFormat:@myTransformableAttribute = %@, myGuidObject] and have it just work. Read the above carefully!

Re: NSExpression with constant NSData value crashes Core Data

2009-05-22 Thread Jerry Krinock
On 2009 May 22, at 13:54, Ben Trumbull wrote: Uhm, No. %@ is the vararg specifier for an NSObject. - stringWithFormat: turns that into a string. Because - stringWithFormat: turns everything into a string. Kinda the point. -predicateWithFormat: does NOT call -description randomly.

NSExpression and CAST (NSPredicate)

2008-11-16 Thread Chris Idou
NSExpression contains the following mysterious information: All methods must take 0 or more id arguments and return an id value, although you can use the CAST expression to convert datatypes with lossy string representations (for example, CAST(, NSDate)). The CAST expression is extended

Re: NSExpression

2008-06-29 Thread mmalc crawford
On Jun 28, 2008, at 10:35 PM, Chris wrote: NSExpression * ex = [NSExpression expressionForFunction: [NSExpression expressionForConstantValue:@BAR] selectorName:@length arguments:nil]; NSPredicate * predicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObject: ex

Re: NSExpression

2008-06-29 Thread Nathan Kinsinger
On Jun 28, 2008, at 11:35 PM, Chris wrote: If anyone has a clue how to use it, I'd be grateful. This was my unsuccessful attempt: NSExpression * ex = [NSExpression expressionForFunction: [NSExpression expressionForConstantValue:@BAR] selectorName:@length arguments:nil]; NSPredicate

NSExpression

2008-06-28 Thread Chris
NSExpression defines this method: + (NSExpression *)expressionForFunction:(NSString *)name arguments: (NSArray *)parameters and the doco provides this example: [NSExpression expressionForFunction:(@selector(random)) arguments:nil]; Isn't that wrong? Can you really pass a selector

Re: NSExpression

2008-06-28 Thread Shawn Erickson
On Jun 28, 2008, at 12:13 AM, Chris [EMAIL PROTECTED] wrote: NSExpression defines this method: + (NSExpression *)expressionForFunction:(NSString *)name arguments: (NSArray *)parameters and the doco provides this example: [NSExpression expressionForFunction:(@selector(random

Re: NSExpression

2008-06-28 Thread Chris
If anyone has a clue how to use it, I'd be grateful. This was my unsuccessful attempt: NSExpression * ex = [NSExpression expressionForFunction:[NSExpression expressionForConstantValue:@BAR] selectorName:@length arguments:nil]; NSPredicate * predicate = [NSCompoundPredicate