NSTimer with anonymous function / block?

前端 未结 9 2345
囚心锁ツ
囚心锁ツ 2020-12-25 10:17

I want to be able to schedule three small events in the future without having to write a function for each. How can I do this using NSTimer? I understand block

9条回答
  •  梦毁少年i
    2020-12-25 10:56

    As of late 2018, you do it precisely like this:

    Timer.scheduledTimer(withTimeInterval: 0.25, repeats: true) { timer in
      print("no, seriously, this works on iPhone")
    } 
    

    This thanks to @JohnnyC !

    Truly strange!

提交回复
热议问题