Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In the previous two tasks, you created Class1 and extended it using categories. In this task, you’ll put the Class1 class and its extension category to work.
To use the base class with categories:
1. | Create a new program named main.m. |
2. | In main.m, enter the code shown in Listing 8.7. This code includes the class1.h and class1extender.h header files to make sure your code knows about Class1 and its extending categories. |
3. | |
4. | In main.m, add the code shown in Listing 8.9. This code calls the print method built into the Class1 class and the print2 method with which you’ve extended Class1. |
5. | Save main.m. |
6. | If you’re using Linux, UNIX, or Windows, create a new makefile named GNUmakefile. |
7. | |
8. | Save GNUmakefile. |
9. | Run the main.m categories program. You should see the output from both the print method and the extending print2 method: This is Class 1. This is Class 1 extended. |