Monthly Archives: April 2020

iOS Persistence with UserDefaults

Persistence can be defined as saving data to a place where it can be re-accessed and retrieved upon restart of the device or app. This can mean non-volatile memory on a device or saving data to remote servers. Persistence is necessary for any app that wants to store data in the long term, that is longer than a lifecycle of a running app, and keep it available to the user.… Read the rest

Benefits and Risks of Singletons

Three singletons types frequently occur throughout iOS SDK and codebases. Let us name them and examine their benefits and risks. They are as follows:

class ExampleOne {
    static let shared = ExampleOne()

    private init {}
class ExampleTwo {
    static let shared = ExampleTwo()
class ExampleThree {
    static var sharedInstance = ExampleThree()

ExampleOne is by the book Singleton implementation.… Read the rest