November 2013
Beginner
325 pages
9h 47m
English
Objective-C has a convenient shortcut called properties that lets you skip declaring instance variables and declaring and implementing accessor methods. Using properties simplifies your class’s code.
In BNRPerson.h, remove the instance variable and accessor method declarations and replace them with two properties: heightInMeters and weightInKilos.
#import <Foundation/Foundation.h> @interface BNRPerson : NSObject // BNRPerson has two properties @property (nonatomic) float heightInMeters; @property (nonatomic) int weightInKilos;{// BNRPerson has two instance variablesfloat _heightInMeters;int _weightInKilos;}// BNRPerson has methods to read and set its instance variables- (float)heightInMeters; ...
Read now
Unlock full access