Chapter 3. Coding in Objective-C

 

This chapter covers

  • Creating classes to match your designs
  • Declaring and implementing messages and properties
  • Connecting code to views in Interface Builder

In the last chapter, you learned how to go from ideas to object-oriented designs. In this chapter, you’ll learn how to code those designs. By iteratively applying the concepts of sketching, designing, and coding, you’ll eventually have an app.

Figure 3.1. Sketch, design, code

To finish an app, you’ll go through this loop many times, refining it on each pass. You already know how to create designs by sending messages to classes that are organized into models, views, and controllers, so you’re halfway there.

Representing those designs as code is the most exacting of the three skills you need to create an app. Your notebook won’t complain if it doesn’t like your sketch or design, but Xcode will put up error after error if you don’t get the syntax exactly right. In reading this chapter, pay attention to every detail about creating classes, messages, and properties.

Creating classes to match your designs

In your designs, you spent a lot of time thinking about what the classes should be, what properties they should have, and what messages they need to respond to and send. You’ve also learned that classes can be in different kinds of relationships with each other. In Objective-C, you’ll see each piece of the class in two places, the header and the module, which together define the parts of a class.

Connecting code to views in Interface Builder

Defining the action message

sitemap