title: "Cannot assign to the result of this expression" - How to set property of optional variable
body: <p>I have a question regarding Swift and optional properties.</p>
  
  <p>Suppose I have the following code:</p>
  
  <pre><code>import Foundation
  
  class MyClass: NSObject {
  
      var parent: MyClass?
      var string: String?
  
      init() {
          super.init()
  
      }
  
  }
  
  let variable : MyClass = MyClass()
  variable.string = "variable"
  variable.parent?.string = "parent"
  </code></pre>
  
  <p>I get an error on the following line saying "Cannot assign to the result of this expression"</p>
  
  <pre><code>variable.parent?.string = "parent"
  </code></pre>
  
  <p>Now, I can suppress this error by replacing the question mark with an exclamation mark which, to my knowledge, makes Swift assume that an object will be there at runtime but it crashes because obviously there isn't an object.</p>
  
  <p>Essentially, how can I set a property on an optional variable without doing something like "if variable.parent"?</p>