Exercises

1. Look up the NSDate class in your documentation. Then add a new category to NSDate called ElapsedDays. In that new category, add a method based on the following method declaration:

-(unsigned long) elapsedDays: (NSDate *) theDate;

Have the new method return the number of elapsed days between the receiver and the argument to the method. Write a test program to test your new method.

2. Modify the lookup: method developed in this chapter for the AddressBook class so that partial matches of a name can be made. The message expression [myBook lookup: @"steve"] should match an entry that contains the string steve anywhere within the name.

3. Using the result from Exercise 2, modify the lookup: method to search ...

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.