问题
For example I have NSManagedObject with x and y double values. I want to get list of point that are located on some distance from provided one. I tried to use next predicate:
[NSPredicate predicateWithFormat:@"(x-%f)(x-%f)-(y-%f)(y-%f) <= %f", point.x, point.x, point.y, point.y, 25*25] . But it doesn't work for some reason :(( .
In my experiments I found out that predicate like (x-1)*2-x >= 0 returns 0 objects even if x is greater than 1, and (x+1)*2-x >= 0 returns all objects. So I suspect that calculations in predicate is not supported, but there are no information about it anywhere I looked
来源:https://stackoverflow.com/questions/13141615/is-there-any-way-to-use-nspredicate-to-filter-objects-using-distance-calculation