【发布时间】:2015-08-03 19:02:43
【问题描述】:
Printing description of localNotification:
{开火日期= 2015 年 8 月 5 日,星期三,上午 9:00:00 印度标准时间,时区 = (null),重复间隔 = NSCalendarUnitDay,重复计数 = UILocalNotificationInfiniteRepeatCount,下一次触发日期 = 星期四, 印度标准时间 2015 年 8 月 6 日上午 9:00:00,用户信息 = (null)}
如您所见,时间是上午 9:00:00,但它永远不会在这里触发我正在做的事情
- 我正在通过更改我的 Mac 时间在模拟器上进行测试,是这样吗?
- 我也厌倦了将我的 mac 时间更改为下一个开火日期,仍然无法正常工作。
- 这些可以在 Live 设备中完美运行吗?
更新代码
var calendar = NSCalendar.currentCalendar()
// calendar.timeZone = NSTimeZone(forSecondsFromGMT: 0)
let comp = NSDateComponents()
//comp.timeZone = NSTimeZone(forSecondsFromGMT: 0)
comp.day = NSDate().day()
comp.month = NSDate().month()
comp.year = NSDate().year()
comp.hour = date.hour()
comp.minute = date.minute()
var grouptimestamp = calendar.dateFromComponents(comp)?.getCurrentTimeStemp()
var minutes = self.getMinutestFromTimestemp(NSDate.getCurrentTimeStemp() - grouptimestamp!)
if minutes > 59 {
println("Missed")
}else if minutes < -5 {
println("Early")
}else{
println("Takenow")
}
UIApplication.sharedApplication().cancelAllLocalNotifications()
var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Myplan"
localNotification.alertBody = "Woww it works!!"
localNotification.fireDate = NSDate(timeIntervalSince1970: NSTimeInterval(grouptimestamp!))
localNotification.repeatInterval = NSCalendarUnit.CalendarUnitDay
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
【问题讨论】:
标签: swift timezone uilocalnotification ios8.4