如何保存创建Core Data对象时的日期和时间 [英] How to save the date and time when a Core Data object is created
本文介绍了如何保存创建Core Data对象时的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要保存&检查当前时间(如果今天)或在Core Data中创建的记录的日期
I want to save & retrive current time (if today) or date of the note created in Core Data
请指导我如何做到这一点。
Please guide me on how I can do this.
推荐答案
创建一个名为Note的核心数据实体,给它一个属性叫
timeStamp
Make a Core Data entity called Note, give it an attribute called timeStamp Set it to type Date.
在创建新注释时,将其分配给当前时间:
When creating a new Note assign it the current time:
[note setTimeStamp:[NSDate date]];
持续注意,就是这样。
这篇关于如何保存创建Core Data对象时的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文