您应该使用 NSDate 存储,并使用 NSDateComponents 呈现。
由于时区的原因,事件出现在错误的日期(例如距真实日期的前 1 天)。
This happens because NSDate is an absolute point in time. You need to do the proper conversions to display based on the users locale. The NSDateComponents (along with NSCalendar) will take care of this.
The Date and Time Programming Guide will tell you all that you need to know, but the first paragraph sets the tone:
There are three main classes used for working with dates and times.
- NSDate allows you to represent an absolute point in time.
- NSCalendar allows you to represent a particular calendar, such as a Gregorian or Hebrew calendar. It provides the interface for most
date-based calculations and allows you to convert between NSDate
objects and NSDateComponents objects.
- NSDateComponents allows you to represent the components of a particular date, such as hour, minute, day, year, and so on.