Singletons in Swift 5

Here’s precisely how I make a singleton,

public class Model
    {
    static let shared = Model()
    // For ocd friends. Add this line: private init() {}

    func test()->Double
        {
        return 3.33
        }
    }

then elsewhere…

class ViewController:UIViewController
    {
    override func viewDidLoad()
        {
        super.viewDidLoad()
        print("Holy singleton test, Batman! ( Model.shared.test() )")
        }
    }

What about in Swift 5?

Any new dramas or insights? Have they perhaps added “actual” singletons, or?

Source: Ios