title: access a class type variable from another class in swift
body: <p>I am trying to learn swift and i am reading this article <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ClassesAndStructures.html" rel="nofollow">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ClassesAndStructures.html</a> . In <code>VideoMode</code> class an object like <code>resolution</code> of type <code>Resolution</code> is created as a property of <code>VideoMode</code> class's .  After that an object <code>let someVideoMode = VideoMode()</code> of <code>VideoMode</code> class's is created and access <code>width</code> property of <code>Resolution</code> struct by <code>someVideoMode.resolution.width</code> . This concept is clear to me. But i am facing problem when i am reading this article <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/OptionalChaining.html#//apple_ref/doc/uid/TP40014097-CH21-ID245" rel="nofollow">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/OptionalChaining.html#//apple_ref/doc/uid/TP40014097-CH21-ID245</a></p>
  
  <p>In this article <code>Person</code> class just create a property<code>var residence: Residence?</code> of <code>Residence</code> class's. Not create an object. After that, create a object <code>john</code> of <code>Person</code> class's and accessing  property of <code>Residence</code> class's. What is happening here? Please tell me, how  <code>Person</code> class access property of <code>Residence</code> class ?</p>