I'm working with a dictionary with SwiftUI and I'm simply trying to add a pair to a dictionary. The dictionary is defined as follows:
@State var dict: [String : Int] = [String : Int]()
Then, in my init() method, I call a function that runs the following code:
if dict["test"] == nil {
dict["test"] = 1
print(dict["test"])
}
However, all the print line only outputs nil, does anyone know why?