allocWithZone: and init of a singleton


In Chapter 9, if you create the singleton using:

The static variable sharedStore is created by sending allocWithZone: to NSObject. That instance is then sent the message init which creates a new NSMutableArray and sets that equal to the allItems variable.

In order to prohibit another instance of sharedStore from being allocated, we override allocWithZone: to quietly return the singleton of sharedStore. But if someone calls this again:

Doesn’t the init message override the NSMutableArray that already exists? Or when the singleton is returned, does the init method get skipped?


Please refer to the previous thread: