10. Control Structures in Objective-C

Chapter 1, “C, the Foundation of Objective C,” covered the basic C language control statements used for looping and branching: if, for, and while. This chapter examines how these statements are typically used in an Objective-C setting. It also covers some additional Objective-C looping constructs, including the Fast Enumeration feature that is new with Objective-C 2.0. Finally, it covers Objective-C’s exception system.

if Statements

As noted in Chapter 3, “An Introduction to Object-Oriented Programming,” Objective-C defines its own Boolean type, BOOL, and the constants YES and NO to represent true and false. A message expression using a method that returns a BOOL, such as the NSArray method containsObject: ...

Get Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.