what's best approach to store lookup date choice (actual value, or look up index)?
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.
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.
精彩评论