So I can create a local notification like this
var localNotification = UILocalNotification()
localNotification.fireDate = NSDate(timeIntervalSinceNow: 7)
localNotification.alertBody = NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: .MediumStyle, timeStyle: .ShortStyle)
localNotification.timeZone = NSTimeZone.defaultTimeZone()
localNotification.repeatInterval = NSCalendarUnit.CalendarUnitMinute
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
This creates a notification with the date right now and then starts firing it off every minute for eternity. If the time the notification was created is 5pm it will say 5pm every time it fires, even if 30 minutes later the time is 5:30.
What do I need to do to make the alert body dynamic?
I read in the docs it expects a string for alertBody so I am having trouble trying to figure out how to set the message body with a function call or a time stamp or a value that changes.
Basically I want my app to calculate a value at the time the notification is about to fire, not at the time it is set, to create the message. The example about uses a notification every minute for symplicty so you can see this code in action. In the real app I want to fire a daily notification at a pre determined time. EG Once a day at 7am and calculate a value at that time.