Using Singleton pattern with dispatch_once in Swift
Hello everyone! I just started learning Swift and am trying to implement the Singleton pattern for a class that will manage application settings. In Objective-C, I used to use `dispatch_once` to ensure that initialization happens only once in a thread-safe manner. Here's an example of how I did it before:\n\n```objc\n+ (instancetype)sharedInstance {\n static MyClass *sharedInstance = nil;\n static dispatch_once_t onceToken;\n dispatch_once(&onceToken, ^{\n sharedInstance = [[MyClass alloc] init];\n });\n return sharedInstance;\n}\n```\n\nIn Swift, I see many examples online, but they often use different approaches: global constants, `private init`, structures with `static let`. I'm confused that `dispatch_once` in Swift 3+ is declared as deprecated. How to properly