存储查找日期选择(实际值或查找索引)的最佳方法是什么?
存储查找日期选择(实际值或查找索引)的最佳方法是什么?就我而言,在 iPhone 应用程序的 CoreData 中。这些选项似乎是:
1)存储实际值(例如整数或浮点数)-但是当用户从值查找列表中修改当前值时,代码必须计算出这是第一个值,并且希望当前查找值列表中存在与它们的值匹配的值。
2)存储查找索引 - 但是如果您想更改查找列表中的值范围,您可能会引入不匹配错误
如果我错过了另一个选项,有什么关于最佳方法或其他方法的建议吗?
PS 例如,如果查找的是“从 3.1、3.2 和 3.3 kg 中选择一个重量,那么您可以存储选项 (1) 3.1,如果这是选择的重量,但是对于选项 (2),您可能只存储 0 (即索引)来指示它是用户想要的第一个选择。
What's best approach to store lookup date choice (actual value, or look up index)? In my case in CoreData for an iPhone application. The options seem to be:
1) Store actual value (e.g. integer or float) - but then when the user goes to modify their current value from a lookup list of values, the code would have to work out which one this is first, and hopefully there is a match for their value within the current list of lookup values.
2) Store lookup index - but then if you wanted to change the range of values in the lookup list you could introduce a mismatch error
Any suggestions re best approach, or another approach if I'm missed another option?
PS Eg so if the look up was for "pick a weight out of 3.1, 3.2 and 3.3 kg, then you may store for option (1) 3.1 if this was the weight picked however for option (2) you might just store 0 (i.e. an index) to indicate it was the first selection the user wants.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白当您询问如何存储“查找日期选择”时,为什么您会说“实际值”是整数或浮点数。 Core Data可以直接存储NSDate对象。只要确保日期的时间部分始终设置为格林威治标准时间午夜,假设您只关心日历日期,而不关心时间。
I don't understand why you'd say that the "actual value" is an integer or float when you're asking how to store a "lookup date choice". Core Data can store NSDate objects directly. Just make sure that the time component of your dates is consistently set to midnight GMT, assuming that you only care about the calendar date, and not the time.