Reputation: 1524
I'm new to Objective C and I know this is a rather trivial question.
I made a subclass of NSObject, defined some new properties and didn't define an initializer in the subclass. What happens when I call this line of code:
CustomClass *cl = [[CustomClass alloc] init];
In this line I call the superclass init method but how do the properties in my subclass get initialized?
Upvotes: 1
Views: 515
Reputation: 318944
All instance variables (the ones backing your properties) are initialized to default values when you create a new object instance.
All object pointers get set to nil
. All primitive types get a value of 0
(BOOL
is set to NO
).
In other words, all properties in your subclass with be set to an appropriate form of "zero".
Upvotes: 1