US>Error Contents
cannot assign a value of type "NSDateFormatter" to a value of type
"NSDate"
US>Error points
notification.fireDate=myDateFormatter
let myDateFormatter=NSDateFormatter()
myDateFormatter.locale=NSLocale(localeIdentifier: "ja_JP")
myDateFormatter.dateFormat="yyyy/MM/dd hh:mm"
let mySelectedDate: NSSstring=myDateFormatter.stringFromDate(sender.date)
dateField.text = mySelectedDate as String
UIAApplication.sharedApplication().cancelAllLocalNotifications();
let setting = UIUserNotificationSettings (forTypes: [.Sound, .Alert], categories:nil)
UIAApplication.sharedApplication().registerUserNotificationSettings(setting)
let notification = UILocalNotification()
notification.fireDate=myDateFormatter
notification.timeZone=NSTimeZone.defaultTimeZone()
notification.alertBody="Notification"
notification.alertAction="OK"
notification.soundName = UILocalNotificationDefaultSoundName
UIAApplication.sharedApplication().scheduleLocalNotification(notification);
As you can see in the error message, myDateFormatter
is an instance of NSDateFormatter
, so it is not NSDate
.
Would you like to substitute fireDate
for sender.date
?
© 2024 OneMinuteCode. All rights reserved.