Skip to content
KnowledgeCity

Swift Beginner: Classes and Structures

Learn about classes and structures.
Preview the first lesson free — get full access to all 6 lessons.
Course: On-Demand
Beginner Provider Mark Nair  6 Lessons ·  40m  in Arabic, German, English, Spanish, French, Portuguese, Chinese 

Course Description

As you begin building more sophisticated projects, you’ll want to create your own types that include properties and other logic. In this module, you’ll learn about two of those: classes and structures.

We use structures in Swift fairly often. You’ll learn how to build your own structs with your own properties and then how to create instances of those structs to add to this flexibility. Swift is also an object-oriented programming language, so you’ll learn about organizing your code into classes and subclasses and how to initialize your properties in both of them. You’ll also learn the basics of subclass and superclass inheritance, which means how properties in a child class can inherit the traits of those properties from the parent class. Finally, we’ll explore property observers, which are chunks of code that keep watching for changes that may happen within your struct and then act accordingly, depending on the logic you have implemented.

What You'll Learn

  • Create your own custom types using structures and classes
  • Build structs with their own properties and create instances of them
  • Initialize properties in both structures and classes using initializers
  • Organize code into classes and subclasses using object-oriented programming
  • Apply subclass and superclass inheritance so child classes inherit parent traits
  • Use property observers to watch for and respond to changes within a struct

Key Takeaways

  • Swift lets you create your own types that include properties and other logic, such as classes and structures.
  • Structures are used in Swift fairly often, and you can build your own structs with custom properties and create instances of them.
  • Swift is an object-oriented programming language, so code can be organized into classes and subclasses with initialized properties.
  • Subclass and superclass inheritance means properties in a child class can inherit the traits of those properties from the parent class.
  • Property observers are chunks of code that watch for changes within your struct and act accordingly based on the logic you implement.

Frequently Asked Questions

What does this course cover?

This module covers creating your own custom types in Swift, specifically classes and structures. It includes making structs, creating instances, initializers, property observers, classes, and inheritance.

Who is this course for?

It is aimed at those beginning to build more sophisticated Swift projects who want to create their own types that include properties and other logic.

What skills will I gain from this course?

You will gain skills in object-oriented programming (OOP), code structure, data structures, structured programming, abstract classes, and application foundation classes.

What is inheritance in this course?

Inheritance covers the basics of subclass and superclass inheritance, meaning how properties in a child class can inherit the traits of those properties from the parent class.

What are property observers?

Property observers are chunks of code that keep watching for changes that may happen within your struct and then act accordingly, depending on the logic you have implemented.