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
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
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
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
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
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
___
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
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
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
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
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
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
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,
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:
-
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
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
];
NSLog(@filtered array results = %@, [keys
filteredArrayUsingPredicate:pred]);
NSComparisonPredicate* exprPred = (NSComparisonPredicate*)[NSPredicate
predicateWithFormat:@SUBQUERY(self, $key, %...@.$key != nil) == 0, obj];
NSExpression* expr = [exprPred leftExpression
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
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
: (NSNumber*) inLatitude
longitude: (NSNumber*) inLongitude
{
NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression
expressionForEvaluatedObject]
selectorName:
@distanceFromLatitude:longitude
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
longitude: (NSNumber*) inLongitude
{
NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression
expressionForEvaluatedObject]
selectorName:
@distanceFromLatitude:longitude:
arguments
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
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
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!
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 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
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
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 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
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
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
32 matches
Mail list logo