Getter methods are given the name of the instance variable minus the underscore.
// Instance variable declarations { float _heightInMeters; int _weightInKilos; } // Getter method declarations - (float)heightInMeters; - (int)weightInKilos;
Setter methods start with set followed by the name of the instance variable minus the underscore. Notice that the case of the setter’s name adjusts to preserve the camel-casing. Thus, the first letter of the instance variable name is uppercase in the setter’s name.
// Setter method declarations - notice difference in casing! - (void)setHeightInMeters:(float)h; - (void)setWeightInKilos:(int)w;
No comments:
Post a Comment