Chapter 2. Object-Oriented Programming with Objective-C

Objective-C is an object-oriented programming language. In this chapter, you’ll learn what this means, how the Objective-C language works, and how your objects exist in the context of Objective-C applications.

Object-oriented programming is by no means a new thing, having shot to popularity in the 1980s. It’s remained the most commonly used programming paradigm and is particularly useful for applications that present some sort of interface to the user, since humans are used to thinking in terms of objects they can see and interact with.

Objective-C takes a fairly idiosyncratic approach to how it implements object-orientation. This provides a number of benefits to you as a programmer, at the slight expense of having to understand a few more details about how it works and what Cocoa expects from your code.

Object-Oriented Programming

When developing any application for any platform, your code should be divided into different parts, where each part is responsible for a different area in your program. This means that the logic for each task that your program performs should avoid interfering with other tasks.

For example, code that talks to a database over the Internet should not be mixed with the code that displays the results to the user. Instead, you should have one section of code that does the database work and another that does the display. When these two sections need to communicate, they should do so over clearly defined interfaces. ...

Get Learning Cocoa with Objective-C, 3rd Edition 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.