Swift Singletons. The Difference When Using Class & Structs

Created by iOSBFree. Understanding the differences between class and struct singletons in Swift iOS.

3.60 (12 reviews)
Mobile Apps
Swift Singletons. The Difference When Using Class & Structs
31 mins
Feb 2022
last update
regular price

What you will learn

Understand why & when you would use the Singleton pattern

Understand the behaviour of a struct singleton

Understand the behaviour of a class singleton

Understand the essential engineering behind these coding decisions


Learn From One Of The 1st iOS Developers In The World

Our instructor Matt, has 13 years of experience in iOS and created the world's first iPhone, iPad and Apple Watch apps. Now, he dedicates his time to recording courses for iOSBFree (pronounced "iOS Be Free").

In This Course

1. We create two singletons in a Playground.

2. Each singleton is created using either a struct or a class.

3. We examine the advantages and disadvantages of each approach

Learning Objectives

· What is a singleton

· The behaviour of a struct singleton

· The behaviour of a class singleton

The Goal Of A Singleton

Together, we’ll examine the behaviour of two different approaches when creating singletons. The more classic approach is to create each singleton using a class due to its memory management - when the singleton is created it will exist in only one area of memory and never be duplicated. However, the opposite can be true when dealing with struct singletons.

Our Recommendation

Our recommendation would be to always use a class singleton due to the principle of a singleton itself, which is to maintain only one of its kind within the system. One manager handles the inflow and outflow of certain behaviour. If we want to ensure that we don’t duplicate our singleton, we should stay away from struct value types that use such behaviour by default.

Sample Code

Sample Code Is Always Included and attached to each video. You can download the same project used in each episode of the course.

This Course Is Free

This course is free. We aim to publish as many short courses as we can to help new iOS Developers apply for jobs in iOS and enter a high paying profession. We want those developers to write great apps that are robust, work correctly, and are maintainable. By supplying this information for free we hope we can reach as many people studying in the pandemic as we can.

Our Service (iOSBFree Ltd)

We are a unique career-building service sharing over 13 years of successful experience shaping the iOS industry into what it is today. Our unique information, point-of-view and service can be utilised to build highly successful and profitable careers in iOS.

A Career In iOS

iOS developers are the most sought after developers in the world! They can earn over £100,000 per year, work remotely and B in high demand for their skills! Subscribe to our YouTube channel and let us reveal all our insider secrets completely for free.

What We Teach

Career building, CV writing, interviewing skills, industry secrets, industry stories, real-life experience, iOS fundamentals, ARC memory management, Swift, architecture and best engineering practices.

Please show your support by enrolling in our course!

What Is SwiftUI?

SwiftUI is a newly released UI Framework introduced to iOS. It aims to solve a lot of problems with apps, such as running on all platforms, reducing bugs, improving stability and bringing more developers to iOS - because it's EASIER to write apps!

Learning SwiftUI is an absolute must for any iOS developer looking to develop a career over the next 5 years.

The Instructor

Check out our Instructor profile (just briefly) and glance over Matt's incredible unparalleled experience. After 13 years of specialising in iOS, he created a company helping people build their own successful and profitable careers in iOS too.

Our unique information cannot be found anywhere else on any platform. We not only teach code, syntax and architecture but we provide tried & tested strategies to boost your career forwards and build a better life!

Want To Learn More Topics?

Please send us an email with the topic you would like to learn in a swift playground and we will happily record, edit and publish it for you. Absolutely for free. Simply email community@iOSBFree.com with the subject heading, "Topic I Want To Learn".

First In The World

Not only is our instructor one of the first iOS developers in the world, but our service is also the first of its kind in the world!
iOSBFree is a truly unique one-of-a-kind service. There is no single other service offering Matt’s level of experience in any other coding course, software engineering tutorial, or career-building service anywhere in the world.

More From iOSBFree

· Download Our FREE CV Template

· Download Our Career BOOSTER Pack

· Enrol In FREE Online Courses (iOS & Swift)

· Read Our Blog

Much love.
The iOSBFree team.
Build a profitable iOS career with iOSBFree!


Welcome to our Mini Course

Welcome to iOSB Free
Why use the singleton design pattern?

Struct Singletons Explained

The struct singleton
Breaking architecture

Class Singletons Explained

The class singleton
Non-breaking architecture



Swift Singletons. The Difference When Using Class & Structs - Price chart


Swift Singletons. The Difference When Using Class & Structs - Ratings chart

Enrollment distribution

Swift Singletons. The Difference When Using Class & Structs - Distribution chart
udemy ID
course created date
course indexed date
course submited by