In an earlier question I mentioned a problem scheduling local notifications. The real cause for the problem was that I used to following code to create the trigger, which does not work:
let calendar = ...
let notificationDate = ...
let dateComponents = calendar.dateComponents(in: calendar.timeZone, from: notificationDate)
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
The following code does work, however:
let calendar = ...
let notificationDate = ...
let dateComponents = calendar.dateComponents([.day, .month, .year, .hour, .minute], from: notificationDate)
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
So the question is: What's happening here? Why does the latter work while the former does not?