Advanced Swift

This course is designed for iOS developers who have a basic understanding of Swift and are ready to take it to the next level.

guide

You don't have a active subscription yet!

To access our video courses, you need to be signed in and have a active subscription. If you are ready to subscribe, click the button down below to check out our pricing ;)

Advanced Swift: Course Overview


Welcome to our Advanced Swift course! This course is designed for beginning iOS developers who have a basic understanding of Swift and are ready to take their skills to the next level. In this course, we will cover a range of advanced topics that will help you become a more proficient and effective Swift programmer.


Extensions


Extensions allow you to add new functionality to existing classes, structures, enumerations, or protocols. This is particularly useful when you do not have access to the original source code. Extensions can add new methods, properties, and subscripts.


extension Int {
    var isEven: Bool {
        return self % 2 == 0
    }
}

Protocols


Protocols define a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. They can be adopted by classes, structures, and enumerations.


protocol Greetable {
    func greet() -> String
}

class Person: Greetable {
    func greet() -> String {
        return "Hello!"
    }
}

Static Functions and Objective-C Functions


Static functions are functions that belong to a type itself rather than an instance of a type. They are called on the type, not on an instance of the type. Objective-C functions are functions that can be exposed to Objective-C runtime, allowing Swift code to interact with Objective-C code.


class Math {
    static func add(a: Int, b: Int) -> Int {
        return a + b
    }
}

@objc class ObjectiveCClass: NSObject {
    @objc func doSomething() {
        print("Doing something")
    }
}

Actors


Actors are a new reference type in Swift that protect access to their mutable state. They are used to handle concurrency by ensuring that only one task can access the actor’s state at a time.


actor BankAccount {
    private var balance: Int = 0
    
    func deposit(amount: Int) {
        balance += amount
    }
    
    func getBalance() -> Int {
        return balance
    }
}

Initializers and De-initializers


Initializers are special methods that prepare an instance of a class, structure, or enumeration for use. De-initializers are called immediately before a class instance is deallocated to perform cleanup.


class Vehicle {
    var make: String
    
    init(make: String) {
        self.make = make
    }
    
    deinit {
        print("\(make) is being deinitialized")
    }
}

Optional Chaining


Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil. If the optional contains a value, the call succeeds; if the optional is nil, the call returns nil.


class Person {
    var residence: Residence?
}

class Residence {
    var numberOfRooms = 1
}

let john = Person()
if let roomCount = john.residence?.numberOfRooms {
    print("John's residence has \(roomCount) room(s).")
} else {
    print("Unable to retrieve the number of rooms.")
}

Advanced Operators


Swift includes several advanced operators that perform bitwise and bit shifting operations, among others. These operators are useful for low-level programming tasks.


let initialBits: UInt8 = 0b00001111
let invertedBits = ~initialBits  // equals 0b11110000

ARQ in Swift


ARQ (Automatic Reference Counting) is a memory management feature of Swift that automatically keeps track of and manages your application's memory usage.


class ExampleClass {
    var someProperty: String
    
    init(someProperty: String) {
        self.someProperty = someProperty
    }
    
    deinit {
        print("\(someProperty) is being deinitialized")
    }
}

Opaque Types


Opaque types enable a function to return a value of some type that conforms to a protocol, without specifying the exact type. This helps in maintaining abstraction and hiding implementation details.


func makeOpaqueContainer() -> some Container {
    return [1, 2, 3]
}

Subscripts


Subscripts are shortcuts for accessing the member elements of a collection, list, or sequence. You can define subscripts in classes, structures, and enumerations.


struct TimesTable {
    let multiplier: Int
    
    subscript(index: Int) -> Int {
        return multiplier * index
    }
}

let threeTimesTable = TimesTable(multiplier: 3)
print("six times three is \(threeTimesTable[6])")

Typecasting


Typecasting in Swift is implemented with the "as" keyword and is used to check the type of a value or to cast a value to a different type. This is particularly useful when working with heterogeneous collections.


let someObjects: [Any] = [0, "Hello", 42.0]
for object in someObjects {
    if let string = object as? String {
        print("Found a string: \(string)")
    }
}

Concurrency


Concurrency in Swift allows multiple pieces of code to run simultaneously, making your app more efficient and responsive. Swift's concurrency model includes async/await, tasks, and more.


func fetchImage() async throws -> UIImage {
    let url = URL(string: "https://example.com/image.jpg")!
    let (data, _) = try await URLSession.shared.data(from: url)
    return UIImage(data: data)!
}

This course will delve into these advanced Swift topics, providing you with the knowledge and skills needed to build more complex and efficient iOS applications. Stay tuned for a deep dive into each of these subjects!

Course Cirriculum

15 amazing sessions!

  • [ SESSION 1 ]

    Welcome to our Advanced Swift course

    ....

  • [ SESSION 2 ]

    Extensions in Swift

    ....

  • [ SESSION 3 ]

    Protocols in Swift

    ....

  • [ SESSION 4 ]

    More Functions in Swift

    ....

  • [ SESSION 5 ]

    Actors in Swift

    ....

  • [ SESSION 6 ]

    Initializers in Swift

    ....

  • [ SESSION 7 ]

    Deinitializers in Swift

    ....

  • [ SESSION 8 ]

    Optional Chaining in Swift

    ....

  • [ SESSION 9 ]

    Advanced operators in Swift

    ....

  • [ SESSION 10 ]

    ARQ in Swift

    ....

  • [ SESSION 11 ]

    Opaque Types in Swift

    ....

  • [ SESSION 12 ]

    Subscripts in Swift

    ....

  • [ SESSION 13 ]

    TypeCasting in Swift

    ....

  • [ SESSION 14 ]

    Concurrency in Swift

    ....

  • [ SESSION 15 ]

    What did we learn

    ....

instructor

Exodai INSTRUCTOR!

Johan t'Sas

Owner and Swift developer!

Resources and Assets

All resources, assets and the syllabus are provided with each course.