title: Connection between variables in Dictionary and other variables in class
body: <p>In my class I use several variables for calculations, but when I initiate object of this class in Controller, I use dictionaries.</p>
  
  <p>This is the simple code:</p>
  
  <pre><code>class MyClass {
  
    var one: Float = 1.0
    var two: Float = 2.0
    var three: Float = 3.0
    var four: Float = 4.0
  
    var dictionary = [String: Float]()
  
    init(type: String) { // Here I use dictionary
      switch type {
        case "type1":
          self.dictionary = ["one": one, "two": two]
        case "type2":
          self.dictionary = ["three": three, "four": four]
        default:
          break
      }
    }
  
    func calculate() -&gt; Float { // And here I use variables
      return one + two
    }    
  }
  </code></pre>
  
  <p>In controller I need dictionaries, because I use keys in <code>UIPickerView</code>s and <code>UITableView</code>s labels and so on.</p>
  
  <p>But I need to make a strong connection between variables in dictionary and variables in class.</p>
  
  <p>So, when I use in controller:</p>
  
  <pre><code>myClass = MyClass(type: "type1")
  
  override func viewDidLoad() {
    super.viewDidLoad()
    myClass.dictionary["one"] = 1.5 // ["one": 1.5, "two": 2.0]
    print(myClass.one) // 1.0 but I need 1.5
  }
  </code></pre>
  
  <p>When I make changes in dictionary, I need to change variables to make further calculations in class with updated variables. Is it possible to make it with declaration of <code>var</code>s and <code>dictionary</code>? Or I need to write a method, which will update variables each time dictionary will change?</p>
  
  <p>Thanks for any help!</p>