How to call a method a.s.a.p. but at earliest in the next run loop iteration?

后端 未结 4 1509
广开言路
广开言路 2021-02-05 10:16

I need a save way to say: \"iOS, I want this method to be executed a.s.a.p., but NOT in THIS run loop iteration. At the earliest in the next, but please not in this one. Thank y

4条回答
  •  天命终不由人
    2021-02-05 10:50

    If you're worried that Apple may someday special-case a delay of 0, you could always specify a delay of 1e-37 or so. Although the documentation for performSelector:withObject:afterDelay: could easily be read to guarantee that the selector will always be scheduled for the next run loop iteration.

    If you're worried that Apple may someday special-case delays less than some arbitrary lower bound, you could always try using NSRunLoop's performSelector:target:argument:order:modes: which the documentation specifically states will schedule execution for the next iteration of the run loop.

提交回复
热议问题