April 2020
Beginner
316 pages
8h 20m
English
To begin with, we'll need to create a class that can conform to the ObservableObject protocol, as it's only going to contain one property. For now, we'll just create this at the bottom of our ContentView.swift file.
Go ahead and add the following code:
class AppData: ObservableObject { @Published var fontColor = Color.black}
We've created a class called AppData. During the course of this book, we'll add various other properties that we'll want our SwiftUI Views to access on a more global scale. We'll start by adding a fontColor variable, which will allow us to set the color of our fonts in one place, but be accessible in another.
We create our variable called fontColor and prefix this with ...
Read now
Unlock full access