Chapter 4. Language and Programming Basics

In This Chapter

  • Getting a handle on statements

  • Working with variables

  • Performing actions with operators

  • Knowing how to make logical decisions in your code

  • Using pointers to access data

  • Getting the hang of using constants

  • Being aware of the Objective-C reserved words

As I mention in Chapter 3, Objective-C is a set of extensions to standard ANSI C. This means that at some point (that is, this chapter), you'll have to sit down and learn the basics of the C instruction set, along with some less than inspiring examples and detailed explanations on the basics of the language — kind of like learning your alphabet. I know all this can be tedious and excruciatingly boring, although when you're just starting out there's no other way (we all have to pay our dues at some point). But once you are done with this chapter, you will switch to learning Objective-C by developing a "real world" application, which I promise is (for the most part) much more interesting. So hang in there.

It All Comes Down to Your Statements

At the end of the day, it's all about the instructions you give the computer. Those instructions are called statements. You can easily recognize a statement because it ends with a semicolon, as shown here:

NSLog(@"This is a statement");

There are a number of different kinds of statements. In this chapter, I show you two of them:

  • Declarations of a variable allow space for data. They look something like this:

    int aNumber;

    Declarations are used to allocate ...

Get Objective-C® For Dummies® 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.