Domanda

Ho un oggetto NSDate, e ho bisogno di controllare se è già passato. Se è così, trasformare quella data nella data di domani, ma non posso perdere le informazioni come TimeZone nel processo.

Potrebbe plz help me?

È stato utile?

Soluzione

NSDate has no timezone info. It's just a thin layer over the number of seconds elapsed since its epoch. You can use a calendar and a timezone to turn it into an NSDateComponents, fiddle with the date there, and then format that into a new NSDate.

Altri suggerimenti

NSDate *date = ...;
if ([[NSDate date] timeIntervalSinceDate:date] > 0) {
    date = [date dateByAddingTimeInterval:24*60*60];
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top