Allocating memory for singleton


#1

I thought I was understanding this singleton design pattern but maybe not :confused:

I thought each class had to reserve memory for its own data. In this case, we need memory to hold the allItems array, ie space for a pointer.

By calling [super allocWithZone.nil], how is the space for allItems being reserved?

I assume the alloc method for super is allocating memory for the parent class.
Who is allocating the space for the array pointer in BNRItemStore?


#2

at first, i was confused too, here is the reference :" + (id)allocWithZone:(NSZone *)zone Returns a new instance of the receiving class.
The isa instance variable of the new instance is initialized to a data structure that describes the class; memory for all other instance variables is set to 0." and the super in objective c is the same as self, only it causes the message routine to search the method from the definition class