MacOS:NSPredicate查找“一对一"的位置.关系不是零 [英] MacOS: NSPredicate find where "one to one" relationship is not nil

查看:41
本文介绍了MacOS:NSPredicate查找“一对一"的位置.关系不是零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 NSPredicate 过滤核心数据获取请求.谓词字符串如下:

I am trying to use NSPredicate to filter a Core Data fetch request. The predicate string looks like this:

"stringProperty = %@ && dateProperty > %@ && oneToOneRelationship != nil"

这不返回任何对象.但是,如果我省略了最后一个子句,它就会这样做.如果我将最后一个子句更改为"oneToOneRelationship = nil" ,则可以.当然,最后两种情况不会返回我真正想要的数据.:)

This is isn't returning any objects. However, if I omit the last clause it does. If I change the last clause to be "oneToOneRelationship = nil" then it does. Of course, these last two cases don't return the data I really want. :)

是否存在一种适当的方式来搜索存在关系但不为零的一对一关系?似乎该谓词应该起作用,但事实并非如此.这是在当前使用Xcode 6.1 beta的Yosemite beta中.

Is there a proper way to search for one-to-one relationships where the relationship exists and isn't nil? It seems like that predicate should be working but it isn't. This is on the current Yosemite beta using Xcode 6.1 beta.

有人有什么主意吗?

推荐答案

实际上,!= nil"测试正常.事实证明,尽管我认为已经建立了一对一的关系,但事实并非如此.因此,该谓词运行正常.当然是我的代码有误.

Actually, the "!= nil" test is working just fine. It turns out that although I thought the one-to-one relationship was being set, in fact, it wasn't. So, the predicate was working properly. It was, of course, my code that was in error.

这篇关于MacOS:NSPredicate查找“一对一"的位置.关系不是零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆