title: swift - how to modify property of object from another class?
body: <p>i added a second viewcontroller to my main viewcontroller. When my second viewcontroller want to modify the object of main viewcontroller its getting error.</p>
  
  <p>first viewcontroller</p>
  
  <pre><code>class ViewController: UIViewController {
  
      var uview:UIView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          uview = UIView(frame: CGRectMake(55, 175, 100, 100))
          uview.backgroundColor = UIColor.greenColor()
          self.view.addSubview(uview)
  
  
          var sec = second()
          self.addChildViewController(sec)
          self.view.addSubview(sec.view)
          sec.didMoveToParentViewController(self)
      }
  }
  </code></pre>
  
  <p>second viewcontroller</p>
  
  <pre><code>class second: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          var button:UIButton = UIButton(frame: CGRectMake(55, 55, 100, 100))
          button.backgroundColor = UIColor.redColor()
          button.addTarget(self, action: "press", forControlEvents:UIControlEvents.TouchUpInside)
          self.view.addSubview(button)
      }
  
      func press(){
          var first:ViewController = ViewController()
          first.uview!.backgroundColor = UIColor.purpleColor()     
      }
  }
  </code></pre>
  
  <p>Error message</p>
  
  <pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
  
  Thread 1:EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP,subcode=0x0)
  </code></pre>