Why @State property will not be set?


Native variable d2 and information has the identical kind, however although d2 has two key worth par, it’s not getting assigned to information, why? Does @State makes it particular?

struct ContentView: View {
    
    @State var information: [String: Any] = [String: Any]()
    @State var res: ValidationResult?

    init() {
        updateValue()
        return
    }
    
    func updateValue() {
        do {
            if let jsonURL = Bundle.important.url(forResource: "person", withExtension: "json") {
                let jsonData = attempt Knowledge(contentsOf: jsonURL)
                guard let d2 = attempt JSONSerialization.jsonObject(with: jsonData, choices: .mutableLeaves) as? [String: Any] else {
                    print("Can't convert to d2")
                    return
                }
                information = d2 // <-------

Similar Posts

Leave a Reply

Your email address will not be published.