I am trying to find and use the one CKRecord that corresponds to the current logged-in user from iCloud throughout my application.
I am fetching the user and saving it from AppDelegate (in a seemingly unnecessarily complicated manner, at that), and then retrieving the record from the AppDelegate when I need it throughout the app.
However, the retrieval of the user takes more time than the app takes to load, and so when the root view controller has loaded, the text label that I have set to be the user's name is empty because the user has not yet been retrieved. This then causes the app to crash because of a "fatal error: unexpectedly found nil while unwrapping an Optional value", and the nil value is the user record.
There must be an easier as well as faster way to retrieve the record of the current user from CloudKit. Any help would be greatly appreciated! :)