【发布时间】:2016-07-14 20:53:41
【问题描述】:
当我的 watchKit 应用程序进入后台时,它会触发委托方法 applicationWillResignActive。方法文档说它可以用来暂停正在进行的任务。
我有一个正在进行的方法,我想通过使用外部方法来停止或破坏。我该怎么做?
示例
func method1(){
// performing some actions
}
func breakMethod1(){
// running this method can stop (break) the execution of method1
}
【问题讨论】:
-
您是否尝试过使用
NSNotifications 来触发不同的事件? -
@dokun1 在这种情况下我如何实现 NSNotification?我之前尝试过执行方法,但不是为了停止它们。
-
如果我正确理解你的问题,你说调用
breakMethod1()会阻止它,是吗?如果是这种情况,请使用NSNotification来触发它。不是这样吗? -
@dokun1 调用 breakMethod1 应该停止执行 method1。你能展示一个实现吗?
-
你能edit your question 包含
method1的实际实现吗?
标签: ios swift methods delegates watchkit