NSPredicate、NsNumber numberWithFloat:0.0 (iPhone)
您好,我有带有数字属性的核心数据数据库。它们是 NSNumber。默认值是 0.0,但是当我尝试执行一些 NSPredicated 获取时,我得到“'NSInvalidArgumentException',原因:'无效谓词:nil RHS'”只是因为属性值为 0.0
创建谓词:
[NSPredicate predicateWithFormat:@"(startValue => %@) AND (endValue <= %@) AND (someId == %@)",startNSNumber,endNSNumber, idString]
我该如何解决这个问题?
hi i have Core Data database with numerical attributes. they are NSNumbers. Default value is 0.0 but when i try to do some NSPredicated fetch, i get "'NSInvalidArgumentException', reason: 'Invalid predicate: nil RHS'" just because attribute value is 0.0
The predicate is created with:
[NSPredicate predicateWithFormat:@"(startValue => %@) AND (endValue <= %@) AND (someId == %@)",startNSNumber,endNSNumber, idString]
how can i solve this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您将浮标添加为对象,而不是浮标?试试这个:
You're adding the floats as objects, not as floats? Try this :
我坚信您的变量之一为零或已自动释放...
尝试以下操作:
如果成功,则问题出在您的变量上。
如果您希望有时
num1
或num2
为nil
,那么您可以将谓词重写为:I strongly believe one of your variables is nil or was autoreleased...
try this:
If this succeeds that the problem is with your variables.
If you expect either
num1
ornum2
to benil
sometimes, then you could rewrite the predicate as:好吧,鉴于您提供的谓词,简单的答案是:
startNSNumber
、endNSNumber
或idString
为 nil。如果您想将NSPredicate
中的某些内容与nil
进行比较,则需要替换为[NSNull null]
,而不是nil
代码>.Well, given the predicate you provided, the easy answer is:
Either
startNSNumber
,endNSNumber
oridString
is nil. If you want to compare something againstnil
in anNSPredicate
, you need to substitute in[NSNull null]
, notnil
.IN NSpredicate 使用字符串值作为 float 字典 key.floatValue 并轻松使用。
我认为这篇文章很有用。
IN NSpredicate use string value as float the Dictionary key.floatValue and easily use.
I thing this post useful.