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 2: Extensions to C > Are You the Boolean Type?

Are You the Boolean Type?

Many languages have a Boolean type, which is, of course, a fancy term for variables that store true and false values. Objective-C is no exception.

C has a Boolean data type, bool, which can take on the values true and false. Objective-C provides a similar type, BOOL, which can have the values YES and NO. Objective-C's BOOL type, incidentally, predates C's bool type by over a decade. The two different Boolean types can coexist in the same program, but when you're writing Cocoa code, you'll be using BOOL.

NOTE

BOOL in Objective-C is actually just a type definition (typedef) for the signed character type (signed char), which uses 8 bits of storage. YES is defined as 1 and NO as 0 (using #define).

Objective-C doesn't treat


  

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