我试图每周重复一次本地通知。
let notification = UILocalNotification()
notification.alertBody = "Notification"
notification.alertTitle = "Notification Title"
notification.repeatInterval = NSCalendarUnit.Weekday
notification.fireDate = notificationDate
notification.soundName = UILocalNotificationDefaultSoundName
notification.category = "Events"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
但这是每天重复而不是每周重复一次?
答案 0 :(得分:3)
您应该使用NSCalendarUnit.WeekOfYear
代替NSCalendarUnit.Weekday
。
注意weekday
表示一周中的一天(即每天)与表示一周的weekOfYear
之间的差异。
答案 1 :(得分:0)
您需要使用notif.repeatInterval = NSCalendarUnit.WeekOfMonth