🧰UIKit + AutoLayout

Lecture Slides

Lecture Video

Lecture Demo

Clone the Repository

git clone https://github.com/intro-to-ios/lec2-uikit
OR git clone git@github.com:intro-to-ios/lec2-uikit.git

Checkout Branches

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

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

Classes Demo Code

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
    }
}

let vin = Student(name: "Vin", major: "Info Sci", age: 20)
vin.major // Prints "Info Sci"

class EngineeringStudent: Student {
    // Inherits properties from the superclass, but you can
    // define other properties specific to this class
    var doesShower: Bool

    // Initializer
    init(name: String, major: String, age: Int, doesShower: Bool) {
        self.doesShower = doesShower // Initialize properties specific to this class
        super.init(name: name, major: major, age: age) // Call superclass' initializer
    }
}

let archit = EngineeringStudent(name: "Archit", major: "CS", age: 20, doesShower: false)
archit.name // Good
archit.doesShower // Good
vin.doesShower // Does not work

Last updated