In this exercise, you practice working with some of the most important Cocoa Foundation classes. You need to use these classes every time you write a Cocoa program, so it is essential that you get used to them.
Create a new Foundation Tool project called Discus, and in the Discus.m file, add code to store information about a few CDs and DVDs in your collection. Store details of each CD/DVD in an NSDictionary and use an NSArray to hold all the dictionaries. The details you might consider storing could include the type of media (CD or DVD); the title; where in your house it is located; and the artist or director. After the data has been stored in the array, retrieve a few pieces of information and print them to the console using the NSLog function.
Finally, look up NSArray in the Xcode documentation and read about the methods writeToFile:atomically: and initWithContentsOfFile:. Use these methods to save the data for your CD/DVD collection to a file on your desktop; then read it back in again. Write the whole NSArray to the console using NSLog to verify that it was read correctly. Also examine the contents of the file on your desktop in a text editor such as TextEdit.
Update the Objective-C version of MyAddressBook so that it allows the user to remove an entry from the address book. Compare the changes you make in the Objective-C version to those you made in Exercise 2 of Chapter 6.