O'Reilly logo

Learning Cocoa by Apple Computer Inc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Objective-C Primer

The Objective-C language is a superset of ANSI C with special syntax and runtime extensions that make object-oriented programming possible. Objective-C syntax is uncomplicated, but powerful in its simplicity. You can mix standard C with Objective-C code. Programmers familiar with C and object-oriented programming techniques often find themselves right at home with Objective-C in a matter of days.

This chapter is divided into two main sections. The first section is a basic language summary listing all additions to the language. The second section summarizes some of the most frequently used aspects of the language.

See Inside Cocoa: Object-Oriented Programming and the Objective-C Language in /Developer/Documentation/Cocoa for complete details.

Language Summary

Objective-C adds a small number of constructs to the C language and defines a handful of conventions used to effectively interact with the runtime system.

Messages

Message expressions are enclosed in square brackets:

[receiver message]

The receiver can be:

  • A variable or expression that evaluates to an object (including the variable self)

  • A class name (indicating the class object)

  • super (indicating an alternative search for the method implementation)

The message is the name of a method plus any arguments passed to it.

Defined Types

The principal types used in Objective-C are defined in the header file objc/objc.h:

TypeDefinition
id

An object (a pointer to its data structure)

Class

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required