Some observations and suggestions for improving Chap 19.
p 118 Creating an Asset class. 3rd paragraph, second sentence. It would help if you added a few words to the end of the sentence: "When an object is being deallocated it is sent the message dealloc automatically by the (part of the system that does this)
Use dissimilar names for the classes and the pointer variables. I found the use of “assets”, “persons” and “employees” as pointer names confusing when I was also trying to think about the interdependencies between the classes named “Asset”, “Person”, and “Employee”. So instead of:
Employee *person = [[Employee alloc]init], maybe…
Employee *awesomeCoder = [[Employee alloc]init]
I don’t think the bit about using @class instead of #import added much of value to the learning objectives of the chapter. It was an unnecessary distraction that didn’t improve my understanding of object instance variables.
The explanation of %@ on p119 could be better. I read this at least a dozen times and I’m still not sure I understand the explanation. Although the code was pretty straightforward. This leads me to my last comments, and that’s about the output.
It’s clear that the first part of the output (e.g., <Employee 0: $0 in assets>) comes from the “description” method in the Asset class. Furthermore, given that the output shows each member of the array of employees, it also leads me to conclude that the output is generated in a loop. The problem I have is that I don’t see any calls to the “description” method, and I don’t see any loops apart from the ones creating and filling the arrays.
Is the “description” method like “dealloc”? Are they both called automatically?
Does “NSLog(@“Employee: %@”, employees);” somehow create this output?
Since (I’m guessing) the dealloc call is being made automatically by (part of the system?) I can see where the deallocation messages comes from, but I think spending a little time explaining how and why the output is created would really help novice programmers like myself. The last 5 lines of the program (not including “return 0”) aren’t in a loop, an explanation of how precisely the output is generated by this code would be welcome.
My $0.02 (so far).
I really like this book. It’s rare to find something that’s clear, brief, simple AND human.