Swift 3 - How to make timer work in background

后端 未结 9 455
忘掉有多难
忘掉有多难 2020-11-30 09:43

i am trying to do an application which can make a timer run in background.

here\'s my code:

let taskManager = Timer.scheduledTimer(timeInterval: 10,          


        
9条回答
  •  日久生厌
    2020-11-30 10:36

    you can go to Capabilities and turn on background mode and active Audio. AirPlay, and picture and picture.

    It really works . you don't need to set DispatchQueue . you can use of Timer.

    Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { (t) in
    
       print("time")
    }
    

提交回复
热议问题