Reputation: 115
class TheOneAndOnlyKraken {
static let sharedInstance = TheOneAndOnlyKraken()
}
This is the blue print of the singleton I implemented. I use my singleton in order to get the user's location throughout all of the project files, and the issue is that in the first time I get that information is returns nil (because it needs a second to setup I guess). This is why I'm interested in instantiating the singleton as soon as the app launches, to avoid working with nil location.
Upvotes: 1
Views: 44
Reputation: 6648
Why not call your singleton in AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
_ = TheOneAndOnlyKraken.sharedInstance
return true
}
Upvotes: 3