In the last demo, you learned about the lifecycle of reference type instances. You used the deinit function to know when an instance is getting deleted. You learned how reference types are different when they get allocated in memory compared to value types.
In this lesson, you built an small app in a playground to store contacts. You used structs, which are value types, and classes, which are reference types. You saw the difference between them when you assigned an instance of either type to a new variable and then changed the value.
Variables of reference types allow you to access the same value from multiple parts of your app. Value types make a copy of their value for each variable you assign them to. Understanding them properly allows you to decide which to use in your code.
Understanding how memory works helps you write better code and use the device’s resources better. That allows you to create better and more stable apps.
In this lesson, you covered the following learning objectives:
Define the difference between classes and structs.
Implement classes and structs with properties and methods.
Use structs and classes to create reusable and efficient code.
Understand how your variables reserve memory and how classes and structs are stored.
In the next lesson, you’ll write code to solve a puzzle, evaluate your solution, and see if you can improve it.
See forum comments
This content was released on Apr 24 2024. The official support period is 6-months
from this date.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Memory Demo
Next: Structs and Classes Quiz
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.