Exercises
1. What will happen if you insert the message expression
[compResult reduce];
into Program 9.1 after the addition is performed? Try it and see.
2. Can the id
variable dataValue
, as defined in Program 9.2, be assigned a Rectangle
object as you defined it in Chapter 8? That is, is the statement
dataValue = [[Rectangle alloc] init];
valid? Why or why not?
3. Add a print
method to your XYPoint
class defined in Chapter 8. Have it display the point in the format (x, y). Then modify Program 9.2 to incorporate an XYPoint
object. Have the modified program create an XYPoint
object, set its value, assign it to the id
variable dataValue
, and then display its value.
4. Based on the discussions about argument and return ...
Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.