如何从plist中读取日期并将其分配给日期选择器?
我有一个带有标题和消息键的 plist 文件。
我想将日期添加到 plist 中。像这样:
我设法 NSLog 日期:
当我尝试将 plist 中的日期分配给日期选择器时,应用程序崩溃了。
self.userDate = [temp objectForKey:@"Date"];
myDate.date = userDate;
如何从plist中读取日期并将其分配给日期选择器?
I have a plist file with Title and Message keys.
I want to add date to plist. like this :
I managed to NSLog the date :
The application crashed when I try to assign date from plist to datepicker.
self.userDate = [temp objectForKey:@"Date"];
myDate.date = userDate;
How to read date from plist and assign it to datepicker?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 userDate 不是 NSDate 对象,它可能是一个字符串。您应该使用 NSDateFormatter 及其 dateFromString 方法将其转换为 NSDate 对象。
the problem is that userDate is not a NSDate object, it's probably a string. You should use a NSDateFormatter and it's dateFromString method to turn it into a NSDate object.