Je dois mettre à jour ma complication watchOS à minuit tous les jours.Création d'une date pour getRequestedUpdateDateWithHandler:
startOfDay
est le début de la journée (c'est-à-dire 12 heures aujourd'hui).
Dois-je ajouter un jour au début d'aujourd'hui comme ça?
func getNextRequestedUpdateDateWithHandler(handler: (NSDate?) -> Void) {
// Call the handler with the date when you would next like to be given the opportunity to update your complication content
let startOfDay = NSDate().startOfDay
let components = NSDateComponents()
components.day = 1
let startOfNextDay = NSCalendar.currentCalendar().dateByAddingComponents(components, toDate: startOfDay, options: NSCalendarOptions())
handler(startOfNextDay)
}
Ou devrais-je pas ajouter un jour au code, et il suffit de faire quelque chose comme ceci:
func getNextRequestedUpdateDateWithHandler(handler: (NSDate?) -> Void) {
// Call the handler with the date when you would next like to be given the opportunity to update your complication content
let startOfDay = NSDate().startOfDay
handler(startOfDay)
}