I’m confused by a statement in the initWithItemName:valueInDollars:serialNumber: method.
From the “Initializers” section in this chapter comes “… how an instance is created: its class is sent the method alloc, which creates an instance of that class and returns a pointer to it, and then that instance is sent the method init, which gives its instance variables initial values.” My understanding is that the [[Class alloc] init] statement creates an instance of that class which would define all its instance variables and then gives them zero or nil initial values. So, I assume in main.m, after the statement “BNRitem *p = [[BNRitem alloc] init]” that all the instance variables of p are declared and defined, and I can assign values to them and use them.
Now, on to the initWithItemName:valueInDollars:serialNumber: method. Why is the statement “dateCreated = [[NSDate alloc] init];” necessary? You don’t have to include “itemName = [NSString alloc] init]”, for example. Aren’t all the instance variables of p declared after “self = [super init]?”
I feel like the answer is obvious but I can’t see it. Any help is much appreciated.