This question already has an answer here:
- When to use lazy instantiation in iOS? 4 answers
Why does the course at Stanford use the lazy initialization for all getters?
Is this correct? Does it have any real advantage?
One advantage (for me) is that the init
method can become much shorter and you need not check if a variable is allocated.