An Xcode 9 project, written in Swift 4, demonstrating how to implement the singleton design pattern.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Swift Singleton Design Pattern.xcodeproj
Swift Singleton Design Pattern
.gitignore
LICENSE.md
README.md

README.md

Swift-Singleton-Design-Pattern

An Xcode 9 project, written in Swift 4, demonstrating how to implement the singleton design pattern.

In this repo and accompanying tutorial, I explain the singleton design pattern, good for protecting shared resources, providing access to some system which contains one and only one instance of an object, supporting one object which performs some type of app-wide coordination, and, as we’ll see here, can be good for providing a value-added wrapper of a built-in iOS singleton.

Here's the app -- resulting from building this project in Xcode -- in action:

alt text

Xcode 9 project settings

To get this project running on the Simulator or a physical device (iPhone, iPad), go to the following locations in Xcode and make the suggested changes:

  1. Project Navigator -> [Project Name] -> Targets List -> TARGETS -> [Target Name] -> General -> Signing
  • Tick the "Automatically manage signing" box
  • Select a valid name from the "Team" dropdown
  1. Project Navigator -> [Project Name] -> Targets List -> TARGETS -> [Target Name] -> General -> Identity
  • Change the "com.yourDomainNameHere" portion of the value in the "Bundle Identifier" text field to your real reverse domain name (i.e., "com.yourRealDomainName.Project-Name").