December 2013
Beginner
576 pages
16h 4m
English
The Objective-C language enables you to access properties using a more convenient syntax. To get the value of the numerator stored in myFraction, you could write this:
[myFraction numerator]
This sends the numerator message to the myFraction object, resulting in the return of the desired value. You can also write the following equivalent expression using the dot operator:
myFraction.numerator
The general format here is as follows:
instance.property
You can use a similar syntax to assign values as well:
instance.property = value
This is equivalent to writing the following expression:
[instance setProperty: value]
In Program 7.1, you set the numerator and denominator of your fraction to 1/3 using the ...
Read now
Unlock full access