Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

355
Views
SwiftUI: Key:Value pair not getting added to dictionary

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?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!