How dispatch_once runs only once?
Answer / Mrinal Kaushick
dispatch_once is a function provided by Apple's Grand Central Dispatch (GCD) library in Objective-C. It ensures that a block of code is executed no more than once during the lifetime of a particular process. This is achieved through an atomic flag, which prevents multiple threads from executing the block concurrently. The first time the function dispatch_once() is called for a specific control variable, the associated block will be executed. Subsequent calls to dispatch_once() with the same control variable will not execute the block again.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is class extension?
What is extern objective c?
What does it mean to be objective?
Does a thread created using performselectorinbackground:withobject: creates its own autorelease pool?
What is the difference between weak and unowned?
What is lazy var?
What does __ block do?
What happen if we send any message to an object which is released?
What is assign property in objective c?
Does objective-c contain private strategies?
What is responder chain?
What is thread safe function?