Swift and Objective-C

Although you will write your classes in Swift, the classes in the Cocoa frameworks are written in Objective-C. Swift was designed to work seamlessly with Objective-C classes. While you can write Cocoa apps in pure Swift, without a line of Objective-C, it is important to have a basic understanding of how Objective-C works.

Objective-C methods (which are only available on classes, not structures) are not called like functions or like Swift methods. Instead of calling a method on an object, Objective-C sends the object a message.

A message consists of a receiver, selector, and any parameters. The selector is the name of the method you want executed. The receiver is the object that you want to execute that ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide 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.