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 the address book for all matches. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access