Exercises

1. Add a new class called ClassC, which is a subclass of ClassB, to Program 8.1. Make an initVar method that sets the value of its instance variable x to 300. Write a test routine that declares ClassA, ClassB, and ClassC objects and invokes their corresponding initVar methods.

2. When dealing with higher-resolution devices, you might need to use a coordinate system that enables you to specify points as floating-point values instead of as simple integers. (iOS uses a structure called CGRect for working with rectangles. All coordinates and sizes are expressed as floating point numbers when working with such rectangles.) Modify the XYPoint and Rectangle classes from this chapter to deal with floating-point numbers. The rectangle’s width ...

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.