> For the complete documentation index, see [llms.txt](https://ios-course.cornellappdev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ios-course.cornellappdev.com/resources/archived-past-semesters/fa25/lectures/uikit-+-autolayout.md).

# UIKit + AutoLayout

{% hint style="info" %}
**If you are having trouble with anything within the course, please reach out to the instructors or make a post on Ed Discussion.**
{% endhint %}

### Lecture Slides

{% embed url="<https://docs.google.com/presentation/d/1LHjsys5QvcJiGQwst_AfNMp2iB3Kee_EJ9RD_s_fCuo>" %}

### Lecture Video

{% embed url="<https://youtu.be/qdFemDAbvP8>" %}

### Lecture Demo Code

{% embed url="<https://github.com/intro-to-ios/lec2-uikit>" %}
If you prefer to download the ZIP, go to Code > Download ZIP in the Github Repository website.
{% endembed %}

{% embed url="<https://github.com/intro-to-ios/lec2-uikit>" %}
If you prefer to download the ZIP, go to Code > Download ZIP in the Github Repository website.
{% endembed %}

#### Clone the Repository

<pre class="language-sh"><code class="lang-sh"><strong>git clone https://github.com/intro-to-ios/lec2-uikit
</strong><strong>OR git clone git@github.com:intro-to-ios/lec2-uikit.git
</strong></code></pre>

#### Checkout Branches

```sh
git checkout origin/1-uilabel
OR git checkout 1-uilabel

git checkout origin/2-uiimageview
OR git checkout 2-uiimageview
```

#### Classes Demo Code

```swift
class Student {
    // Properties
    var name: String
    var major: String
    var age: Int

    // Initializer
    init(name: String, major: String, age: Int) {
        self.name = name
        self.major = major
        self.age = age
    }
}

// Creating an instance of Student
let jay = Student(name: "Jay", major: "CS", age: 67)
// Access properties like below
jay.name
jay.major
jay.age

// NOTE: the super class of `EngineeringStudent` is `Student`
class EngineeringStudent: Student {
    // Inherits all properties and function from 'Student'
    // Define more properties
    var doesShower: Bool

    init(name:String, major:String, age: Int, doesShower: Bool) {
        self.doesShower = doesShower // Initalize property specific to this class
        super.init(name: name, major: major, age: age) // Call the super class's initializer
    }
}

// Creating an instance of EngineeringStudent
let asen = EngineeringStudent(name: "Asen", major: "CS", age: 22, doesShower: false)
asen.doesShower // This works fine since asen is an EngineeringStudent
jay.doesShower  // This DOESN'T work since jay is a Student. `doesShower` 
                //    is a property of EngineeringStudent but not Student
```
