allocWithZone: and init of a singleton


#1

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?


#2

Please refer to the previous thread:
http://forums.bignerdranch.com/viewtopic.php?f=221&t=4423