Instruction

Heads up... You're reading this book for free, with parts of this chapter shown beyond this point as scrambled text.

SwiftUI

SwiftUI is Apple’s new declarative UI framework for building apps across all of their platforms. Unlike UIKit and AppKit, which are based on Objective-C, SwiftUI is built for Swift using modern programming paradigms. One of these is moving away from inheritance and using protocols to build your views instead.

In Objective-C, all views are subclassed from UIView, which in turn is a subclass of NSObject — the base class for all objects in Objective-C. This meant your view inherited all the behavior from UIView automatically. With SwiftUI, this is no longer the case.

SwiftUI Views

In SwiftUI, all views conform to the View protocol. View represents a part of your user interface. It requires a single property: body, which returns another View. This allows you to create lightweight views that you can build on top of each other.

HStack {
    Text(person.name)
    Text(person.age)
}
See forum comments
Download course materials from Github
Previous: Introduction Next: Demo 1