iOS Object-Oriented Objective-C Diving Deeper - Classes, Properties and Methods Custom Classes Continued

Can't understand 2 lines in the code. Details below.

First I paste the code:

-(id) init {

    self = [super init];

if (self) {

    self.itemsOrdered = [[NSMutableArray alloc] init];


return self;


We already assigned the value which is returned by the init method from the super class. If we did this why do we have to check if self is empty or not ? Are there situations where we can get back a "no value" from super?

table1.itemsOrdered = [[NSMutableArray alloc] init];

I need a more detailed explanation especialy on the left side of the = .

This line is confusing to me because until now we declared an NS type array like this: NSMutableArray *nameOfArray = [[NSMutableArray alloc]init];


table1 - is the object from the TableCheck Class

[[NSMutableArray alloc] init] - allocates and initializes a space in the memory


Gabe says that itemsOrdered is the array. Is this a shortened way to declare an array ? In the TableCheck Class subtotal, tip, isTakeOut were declared in the header file at the @property section. It is not mandatory to declare all objects in @property that will be used in the program? Does the . operator in table1.itemsOrdered returns a value ?

If the dot operator can be replaced by brackets, then why brackets aren't working here?

//using the dot syntax
table1.itemsOrdered = [[NSMutableArray alloc] init];

//using brackets
[table1 itemsOrdered] = [[NSMutableArray alloc]init];