Question, _privateItems


#1

I’m not sure if I skipped something, in initPrivate, Why did we used the _privateItems instead of self.privateItems.

-(instancetype)initPrivate
{
     self = [super init];
     if (self){
           _privateItems = [[NSMutabaleArray alloc]init];
      }
     return self;
}

while in allitems we use self.privateItems instead of _privateItems.

-(NSArray *)allItems
{
    return self.privateItems;
}

Thank you…


#2

The reason for that is explained in Programming with Objective-C:

  • Encapsulating Data/Access Instance Variables Directly from Initializer Methods

#3

Thank you ibex10