开发者

Storing time (hours:minutes) in CoreData

开发者 https://www.devze.com 2023-03-21 05:11 出处:网络
How should I properly store hour:minute data of my entity in CoreData? In .NET I could use TimeSpan class, how about objective C?

How should I properly store hour:minute data of my entity in CoreData? In .NET I could use TimeSpan class, how about objective C? The options I see: 1)use CoreData Date type (NSDate?) and ignore every component except for hour and minute 2)use custom 开发者_运维百科type based on string stored as "HH:MM" 3)store two integers

What would you recommend?


I would use the NSTimeInterval class, much like the TimeSpan .NET class.


NSTimeInterval is the correspondant data type: iphone - store NSTimeInterval on a coredata

However, if your data is large, I would suggest the optimization to store two integers instead. If you decide to later on also store seconds, the NSTimeInterval solution is a more flexible one.

0

精彩评论

暂无评论...
验证码 换一张
取 消