On p. 218 (Kindle edition) it says about the instance variable declarations in Appliance.h:
“Objective-C compiler trivia: When compiling for iOS or a 64-bit Mac OS X program you don’t need to declare the instance variables. The @property/@syntheisze calls are sufficient …”
I created the OwnedAppliance subclass of Appliance and added this description method (similar to one for Appliance):
return [NSString stringWithFormat:@"<%@: %d volts %@>", productName, voltage, [ownerNames allObjects]];
If the instance variables productName and voltage are not declared in Appliance.h file then I get an error in the above method:
“Use of undeclared identifier ‘productName’” unless I synthesize productName and voltage at the beginning of OwnedAppliance.m:
@synthesize productName, voltage
If I add productName and voltage instance variables back in Appliance.h then all works fine without sythesizing productName and voltage in OwnedAppliance.h.
Is this expected behavior? Was my mistake in not realizing I had to synthesize these variables in each subclass if I wanted to used them in?
I am using Xcode 4.4.1 on a 64 bit iMac.