English 中文(简体)
预测数学故障
原标题:CoreData NSPredicate math malfunction

首先,这是我第一个问题,

你们有没有注意到 NSPPrevituate的怪异行为数学功能?

举个例子:

1) 我有离境舱 与接口:

@interface OTDeparture : NSManagedObject
@property (nonatomic, retain) NSNumber * position;
@end

i 2) 创建获取请求时使用前提 :

NSPredicate *predicate=[NSPredicate predicateWithFormat:@"(position-1)*(position-1) > 0"];

结果总是零对象(预言总是 NO) 。 格式“ (2-1) * (2-1) & gt; 0” 和“ (position-1) *position & gt; 0” 也会做同样的事情 。

这些上游格式工作如预期(返回对象:预期返回对象):

"2*(position-1) > 0"
"2*2 > 0"
"position-3 > 0"

我做错什么了,还是这真的是虫子?

问题回答

Seems like you re right, there are some in CoreData :(( I have the same issue - Is there any way to use NSPredicate to filter objects using distance calculation between points in CoreData seems like the only way to receive what you want is to use predicateWithBlock: method, though I haven t tried it myself yet. And note that predicateWithBlock: works only for in-memory stores. So most probably you will end up filtering the data by just going through all entities, of course you can try to make at least some filtering before doing this.





相关问题
Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...

Math Overflow -- Handling Large Numbers

I am having a problem handling large numbers. I need to calculate the log of a very large number. The number is the product of a series of numbers. For example: log(2x3x66x435x444) though my actual ...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Subsequent weighted algorithm for comparison

I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2 s value (1.5) is more ...

热门标签