0
計時器在計時器中是如何工作的?Swift 3計時器在計時器
func startSequenz()
{
for mainCell in mainTable {
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector:#selector(ViewController.run), userInfo: nil, repeats: true)
}
}
func run()
{
for cell in table{
timer2 = Timer.scheduledTimer(timeInterval: 1, target: self, selector:#selector(ViewController.run2), userInfo: nil, repeats: true)
}
timer!.invalidate()
}
func run2()
{
currentSteps! += 1
print("\(currentSteps!)")
timer2!.invalidate()
}
執行func run2()
永不止息。我的目標是延遲執行run2和sleep(1)
freez的GUI。
UPDATE:
從來就使用湯姆Ë答案,它部分的工作。但是GUI在執行結束時只刷新一次。
基本上它可以工作,但是你對**許多**單元使用**一個**(同一個)定時器,這是行不通的。 – vadian
好吧我看到每個循環都會創建一個新實例。我該如何解決它?我現在無法獲得解決方案。 – ZombieIK