【发布时间】:2016-06-23 01:21:59
【问题描述】:
这是我在 Simulator(Watch) 上工作的一些 watchOS 代码:
.....
let interval = 60.0
NSTimer.scheduledTimerWithTimeInterval(interval,
target: self,
selector: #selector(InterfaceController.timerDidEnd(_:)),
userInfo: nil, repeats: false)
.....
func timerDidEnd(timer:NSTimer) {
print("Time is over! Please wake up!")
}
我从 Xcode 运行应用程序,上面代码的第一部分被执行。然后我按下 Command-Shift-H,应用程序进入后台。
一分钟后,我在调试控制台中看到消息:时间结束!请醒来!
一切都如我所料。我的问题是:
我应该在函数 timerDidEnd() 中写什么,以便让应用从模拟器的后台唤醒,而不是仅仅在调试器中打印当前消息?
【问题讨论】: