方法一
<code class="hljs scss has-numbering"> <span class="hljs-function">dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<span class="hljs-number">2.0</span> * NSEC_PER_SEC)</span>), <span class="hljs-function">dispatch_get_main_queue()</span>, ^{
<span class="hljs-comment">//寫要發生的代碼;2秒以後發生</span>
});</code>
方法二
<code class="hljs smalltalk has-numbering"> [<span class="hljs-keyword">self</span> <span class="hljs-method">performSelector:</span><<span class="hljs-array">#(發生的方法)</span>#> <span class="hljs-method">withObject:</span><<span class="hljs-array">#(id)</span>#> <span class="hljs-method">afterDelay:</span><<span class="hljs-array">#(幾秒以後發生)</span>#>]</code>