I have store with entities that have coords (x, y, z). I want to fetch them by using predicate like @"sqrt(x*x + y*y + z*z) < distance".
Is there any way to do this?
I've tried to do thi with predicateWithFormat:
I even wrote a lot of code that looks like
NSExpression * dxExpression = [NSExpression expressionForFunction:@"from:subtract:"
arguments:[NSArray arrayWithObjects:
[NSExpression expressionForConstantValue: [NSNumber numberWithFloat:currX]],
[NSExpression expressionForKeyPath:@"self.xCoord"], nil]
];
NSExpression * dxSqrExpression = [NSExpression expressionForFunction:@"multiply:by:"
arguments:[NSArray arrayWithObjects:dxExpression, dxExpression, nil]
];
But it works only for not hierarchical expressions. I.e, So dxExpression works fine, but when I'm trying to use dxSqrExpression, I'm getting error
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Unsupported function expression (-140.857 - #self.xCoord) * (-140.857 - #self.xCoord)'
I've tried without self, but this doesn't work too.
Any help will be appreciated, thanks.