Chapter    11

Creating Classes and Objects

The heart of programming in Swift using Xcode is object-oriented programming. The main idea is to divide a large program into separate objects where each object ideally represents a physical entity. For example, if you were creating a program to control a car, one object might represent the car’s engine, a second object might represent the car’s entertainment system, and a third object might represent the car’s heating and cooling system.

Now if you want to update the part of a program that controls the car’s engine, you just have to modify or replace the object that controls that car engine. Objects not only help you better understand how different parts of a program work together, but also isolate ...

Get Swift OS X Programming for Absolute Beginners 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.