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
:
Type | Definition |
---|---|
id
|
An object (a pointer to its data structure) |
Class |
Get Learning Cocoa 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.