Repeating notifications

Maybe something like this?

// Make a list to hold the notification times
var datComponentsList = [DataComponents]()

// Add the first dateComponents
var dateComponents1 = DateComponents()
dateComponents1.hour = 9
dateComponents1.minute = 00

// Append to the list of dateComponents
dateComponentsList.append(dateComponents1)

// Create the second notification time five hours later
var dateComponents2 = DateComponents()
dateComponents2.hour = 14
dateComponents2.minute = 00
// Append to the list of dateComponents
dateComponentsList.append(dateComponents2)

// Repeat for third and so on
// Create the second notification time five hours later
var dateComponents2 = DateComponents()
dateComponents3.hour = 19
dateComponents3.minute = 00
// Append to the list of dateComponents
dateComponentsList.append(dateComponents3)

// Loop through the list of dateComponents creating a notification for each one
for i..<dateComponentsList.count {
  let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents[i], repeats: true)
  let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger:    trigger)
                            
  UNUserNotificationCenter.current().add(request)
}

There’s a more elegant way to write this code as well, where you can create a loop that creates notification events up until a certain hour etc.

Also for testing purposes, maybe it’s better to test this five minutes apart. In that case, whatever time it is where you are, change the minutes versus the hour. You might also be able to change the date/ time of the simulator for this.