【发布时间】:2015-06-03 12:23:17
【问题描述】:
我是 iOS 开发的新手,但已经创建了应用程序,并且我正在尝试在设定的时间创建每日通知。目前,通知在给定的日期/时间执行一次。我不确定如何使用 repeatInterval 方法来每天安排它。每天重复通知的最佳方法是什么?任何帮助将不胜感激(Y)。
var dateComp:NSDateComponents = NSDateComponents()
dateComp.year = 2015;
dateComp.month = 06;
dateComp.day = 03;
dateComp.hour = 12;
dateComp.minute = 55;
dateComp.timeZone = NSTimeZone.systemTimeZone()
var calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
var date:NSDate = calender.dateFromComponents(dateComp)!
var notification:UILocalNotification = UILocalNotification()
notification.category = "Daily Quote"
notification.alertBody = quoteBook.randomQuote()
notification.fireDate = date
notification.repeatInterval =
UIApplication.sharedApplication().scheduleLocalNotification(notification)
【问题讨论】:
标签: ios swift cocoa-touch uilocalnotification