I'm trying to take in a time value as a string, then have a notification use that value for it's trigger to display. My issue is the notification takes in this format to set it's time:
var dateComponents = DateComponents()
dateComponents.hour = 06
dateComponents.minute = 30
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
and I'm currently implementing the following from this Stack Overflow post to separate out the int values from the string.
let time = "7:30" //Would like to pass in "7:30 PM" instead
let components = time.characters.split { $0 == ":" } .map { (x) ->
Int in return Int(String(x))! }
let hours = components[0]
let minutes = components[1]
Neither allow for any AM/PM information. Is there a simple way to take in the time of day and set a notification up based on that input? Thanks!