Quick tip: using singleton pattern

So far I saw many examples, but not every of them is valid, follow my rules and you will get proper singleton pattern.

in MySingleton.h file:

in MySingleton.m file:

And thats all. The key is to use dispatch_once which will guarantee code inside will be executed only once per whole app lifetime. You can use it like this:

Leave a Reply