Here - I rephrased your questions:
What does [super allocWithZone:NULL] do?
This is the same as saying [super alloc] . The withZone part is related to where your object will be stored in memory. In practice, it would be very rare to use it. See this question for more information - what is the difference between alloc and allocWithZone :?
Why the retain method returns itself (and does not increment the save counter)
Singletones persist throughout the life of your application β you donβt care about the hold account, because there is no situation in which you would like to release your singleton. retain returns self as politeness and agreement (and allow nested expressions).
If Singleton has some instance variables in it, where should they be initialized?
To you. You usually initialize them in the init method, as in a regular object.
source share