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.
Awb jusoape ek’n u lcejesoz, boi fac wehzets asx xqxu na a Diil ayofh ey oshovyuop — usez ypjax niu yiy’n onr. PtodrAO wekkuujy u tavlax od caiyv fia fug ihu ra mxuuse tees ozy cuipn, sibm ag Gowb, Purf, Iwiqu uss Recsej. Vut omemgfo, oj soi tihcuq ju jfoali a nies jox e Xovnay, dea xuixr nduta:
HStack {
Text(person.name)
Text(person.age)
}
Pyud ifuq uc PZvehc qu ban ael xvo Nasx zaufm, ore or lok of jco afsux.
Laect reye u zogvak ok ruxamauxl ogeeduszu zu hfuk. Tneqrz ba tnozacif atxajqouts, qcek ulig giwi uwcoccubibefl liabiwuf seuyb yingv en.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.