Cannot use a predicate that compares dates in Magical Record

荒凉一梦 提交于 2019-11-28 14:34:11
Martin R

The problem is the name "updated" of your attribute. It conflicts with the isUpdated method of NSManagedObject. (See Core Data NSPredicate "deleted == NO" does not work as expected for a similar issue with a "deleted" attribute.)

If you rename your attribute, everything works as expected.

It also looks to my that your predicate is formatted correctly. Here are a couple things you can do:

1) When debugging this, print out that predicate. You should see something like:

updatedDate < {some integer value}

Dates are stored as integers under the covers, and a predicate converts it properly as well. If your predicate isn't printable in the debugger, you'll know right away

2) Check your updatedDate type. Make sure that's a date (I trust it's already a date, but you didn't specify in your question)

3) Make sure your Node object has the updatedDate attribute on it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!