Using dispatch_once_t per object and not per class

前端 未结 3 1229
孤城傲影
孤城傲影 2020-12-10 14:50

There are multiple sources calling a particular method, but I would like to ensure that it is called exactly once (per object)

I would like to use syntax like

<
3条回答
  •  情话喂你
    2020-12-10 15:12

    dispatch_once() executes its block once and only once for the lifetime of an application. Here's the GCD reference link. Since you mention that you want [self _finishOnce] to happen once per object, you should not be using dispatch_once()

提交回复
热议问题