Modern Swift API Design
Show Apple's description.
Every programming language has a set of conventions that people come to expect. Learn about the patterns that are common to Swift API design, with examples from new APIs like SwiftUI, Combine, and RealityKit. Whether you're developing an app as part of a team, or you're publishing a library for others to use, find out how to use new features of Swift to ensure clarity and correct use of your APIs.
The most important goal as an API designer: Clarity at the point of use.
It can be used to expose all the properties of a hidden object as if they belonged to the main object.
- Provides similar benefits to the built-in lazy
- Eliminates boilerplate.
- Documents semantics at the point of definition.
Property Wrappers can be seen as generic getters and a setters:
We can even pass values to the property initializer: