我有下面的代码:
var notification = UILocalNotification()
notification.alertBody = "Message" // text that will be displayed in the notification
notification.fireDate = NSDate() // right now (when notification will be fired)
notification.soundName = UILocalNotificationDefaultSoundName // play default sound
let calendar = NSCalendar.currentCalendar()
let components = calendar.components([.Minute], fromDate: NSDate())
notification.repeatInterval = NSCalendarUnit.CalendarUnitHour // this line defines the interval at which the notification will be repeated
UIApplication.sharedApplication().scheduleLocalNotification(notification)但它已被弃用。搜索了很多次,但无法将其转换为Swift2。有人能帮我解决这个问题吗:
notification.repeatInterval = NSCalendarUnit.CalendarUnitHour发布于 2016-01-21 03:29:02
Swift 2中的枚举比Objective-C中的要好得多。
尝试下一行:
notification.repeatInterval = NSCalendarUnit.Hour它应该是有效的。
https://stackoverflow.com/questions/34908764
复制相似问题