Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Using Arrays and Dictionaries > Creating a Mutable Dictionary

Creating a Mutable Dictionary

You can extend a mutable dictionary by adding new items or reduce it by removing items. You’ll see how to create a mutable dictionary in this task, and you’ll see how to extend it in code in the next task.

To create a mutable dictionary:

1.
Create a new program named createmutabledictionary.m.

2.
In createmutabledictionary.m, enter the code shown in Listing 9.18.

This code creates an object of the NSMutableDictionary class.

3.
Add the code to display a message indicating that the creation process went smoothly and to deallocate the memory used by the mutable dictionary before ending the program (Listing 9.19).

4.
Save createmutabledictionary.m.

5.
Run the createmutabledictionary.m program.

You should see the following:

Created mutable dictionary.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint