Chapter 2. Objective-C and Cocoa

This chapter presents the main features of the Objective-C language under the Cocoa environment. Section 2.1 introduces the main concepts behind classes in Objective-C. In that section, you learn how to declare a new class, define it, and use it from within other classes. You also learn about important Cocoa classes and data types.

After that, in Section 2.2 you learn about memory management in the iPhone OS. You learn how to create new objects as well as how to deallocate them, and you also learn your responsibility when obtaining objects from Cocoa frameworks or other frameworks.

Section 2.3 introduces the topic of Objective-C protocols. There, you learn how to adopt protocols and how to declare new ones as well. Section 2.4 covers properties, an Objective-C language feature that allows you to access instance variables using the dot notation. The concept of categories is the subject of Section 2.5. These allow you to extend existing classes by adding new methods. Posing is another technique that is slightly different from categories. Posing allows you to replace a given class with one of its descendants. This is discussed in Section 2.6.

Exceptions and error handling are important features in any modern language. Section 2.7 covers both of these techniques and shows you the appropriate use of each feature. After covering exceptions and errors you are exposed to the concept of key-value coding (KVC) in Section 2.8. KVC is an important and widely used ...

Get iPhone SDK 3 Programming: Advanced Mobile Development for Apple iPhone and iPod touch 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.