SA
Skip to main content

Creating Observable Object in SwiftUI

Creating Observable Object in SwiftUI

@EnvironmentObject var autocomplete: TopAutocomplete
import Foundation
class TopAutocomplete: ObservableObject {
@Published var list: [String] = []
var action: (String) -> Void
init(action: @escaping (String) -> Void) {
self.action = action
}
}