Last active
August 31, 2018 04:13
-
-
Save skreutzberger/3f51fe7885eda4f25aee to your computer and use it in GitHub Desktop.
get iCloud User ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CloudKit | |
/// async gets iCloud record ID object of logged-in iCloud user | |
func iCloudUserIDAsync(complete: (instance: CKRecordID?, error: NSError?) -> ()) { | |
let container = CKContainer.defaultContainer() | |
container.fetchUserRecordIDWithCompletionHandler() { | |
recordID, error in | |
if error != nil { | |
print(error!.localizedDescription) | |
complete(instance: nil, error: error) | |
} else { | |
print("fetched ID \(recordID?.recordName)") | |
complete(instance: recordID, error: nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
container.fetchUserRecordIDWithCompletionHandler() { ... }
should probably becontainer.fetchUserRecordIDWithCompletionHandler({ ... })