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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10. Cocoa Data Types > Working with Numbers

10.1. Working with Numbers

When you program in Objective-C, you can use all the usual standard C numerical data types for making calculations. If you want to use these values with Cocoa's array objects, however, you're left out in the cold. For this reason, Cocoa offers you the NSNumber class. One of its great uses is to wrap numbers in a Cocoa object, for use with other objects, such as NSArray. The NSArray class is an array class that comes with the Foundation Kit. You hear more about it later in this chapter.

To create an NSNumber object based on an integer value of 42, use code like this:


  

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