This code give err instance member theName cannot be used on type myClass
any suggestions?
//
// ContentView.swift
// myTest
//
// Created by N.N on 2020-11-25.
//
import SwiftUI
struct ContentView: View {
var body: some View {
Text(MyClass.theName as! String)
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
class MyClass {
var theName: String?
init() {
theName = "myName"
}
}
any suggestions?
//
// ContentView.swift
// myTest
//
// Created by N.N on 2020-11-25.
//
import SwiftUI
struct ContentView: View {
var body: some View {
Text(MyClass.theName as! String)
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
class MyClass {
var theName: String?
init() {
theName = "myName"
}
}