In this section, we'll recapitulate how the most common Cocoa design patterns translate to Swift. You may already be very familiar with those design patterns as they are found throughout Cocoa.
Originally, Cocoa was designed as the high-level API to interface with macOS in Objective-C. Originally, it comprised three frameworks:
- Foundation
- AppKit
- Core Data
These frameworks are designed with a common rationale and a set of design patterns we encounter and work with constantly through all Apple SDKs.
Delegation is one of the most common design patterns when working with Apple SDKs. Delegation is a pattern that facilitates the communication between two objects, the first one, which we'll call the source and the other, the delegate. The source can be anything from a view, such as UITableView / UITableViewDelegate
, or a manager, such as CLLocationManager / CLLocationManagerDelegate
.
In every case, the delegation pattern facilitates a many-to-one communication...