1
NSArray *items;
NSArray *items = nil;

Is there any difference in these two statements in Objective-C?

Gaurav Sharma
  • 2,680
  • 3
  • 26
  • 36
  • This might help you to understand `If an object does not implement an initializer, Cocoa invokes the initializer of the nearest ancestor instead.` – Anoop Vaidya Nov 25 '14 at 10:52

1 Answers1

2

Objects are initialized to zero or nil before the initializer runs.

Then check this for more info:

It isn’t necessary to initialize all instance variables of an object explicitly, just those that are necessary to make the object functional. The default set-to-zero initialization performed on an instance variable during allocation is often sufficient. Make sure that you retain or copy instance variables, as required for memory management.

Jose Luis
  • 3,307
  • 3
  • 36
  • 53