DatePicker Stopping CoreData Work

大兔子大兔子 提交于 2019-12-01 14:03:54

Remember NSDate saves not only DD/MM/YYYY but also HH:MM:SS.

At a guess I think when you pick a DD/MM/YYYY from the picker, it saves with a default time of 0:00:00 but in the case above when you set the picker date to now you are actually manipulating the HH:MM:SS to something else (even though you don't see it manually).

To illustrate what I'm trying to say, when you fetch is with a predicate of (dateSaved == picker.date) it is looking for a date in the format DD/MM/YYYY 00:00:00 and for arguments sake you may have saved it on DD/MM/YYYY 09:00:01.

You will need to do some formatting of your NSDate attribute if you want this to work.

Datepicker is by default set to todays date only. You don't need to do it manually.

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