Adding delay between execution of two following lines

前端 未结 7 1723
陌清茗
陌清茗 2020-12-07 13:15

I need to add delay between the execution of two lines in a(same) function. Is there is any favorable options to do this?

Note: I don\'t need two di

相关标签:
7条回答
  • 2020-12-07 13:47

    You can use the NSThread method:

    [NSThread sleepForTimeInterval: delay];
    

    However, if you do this on the main thread you'll block the app, so only do this on a background thread.


    or in Swift

    NSThread.sleepForTimeInterval(delay)
    

    in Swift 3

    Thread.sleep(forTimeInterval: delay)
    
    0 讨论(0)
提交回复
热议问题