O'Reilly logo

Programming in Objective-C, Sixth Edition by Stephen G. Kochan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required