Objective-C delay action with blocks

后端 未结 4 884
眼角桃花
眼角桃花 2020-12-08 00:12

I know that there are several ways of delaying an action in Objective-C like:

performSelector:withObject:afterDelay:

or using NSTimer

4条回答
  •  北海茫月
    2020-12-08 00:59

    Xcode 11.3.1 (at least, and also other versions of Xcode) provides a code snippet to do this where you just have to enter the delay value and the code you wish to run after the delay.

    1. click on the + button at the top right of Xcode.
    2. search for after
    3. It will return only 1 search result, which is the desired snippet (see screenshot). Double click it and you're good to go.

提交回复
热议问题