From 6d5e653413520404bec6bb5a2a71086c3aea6316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Pinto=20Castillo?= Date: Sat, 3 Dec 2016 23:58:13 +0100 Subject: [PATCH] Adds user identifier usage to demo app --- CloudKitCurrentUser/CurrentUser.swift | 1 + Demo/Base.lproj/Main.storyboard | 19 +++++++++++++++---- Demo/ViewController.swift | 11 +++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CloudKitCurrentUser/CurrentUser.swift b/CloudKitCurrentUser/CurrentUser.swift index 1b566c1..9b4fa4f 100644 --- a/CloudKitCurrentUser/CurrentUser.swift +++ b/CloudKitCurrentUser/CurrentUser.swift @@ -90,6 +90,7 @@ public class CurrentUser { isLoadingUserIdentifier = true CKContainer.default().fetchUserRecordID { recordID, error in self.userIdentifier = recordID?.recordName + self.isLoadingUserIdentifier = false for completionBlock in self.userIdentifierCompletionBlocks { DispatchQueue.main.async { completionBlock(self.userIdentifier, error) diff --git a/Demo/Base.lproj/Main.storyboard b/Demo/Base.lproj/Main.storyboard index 20676e5..66818ba 100644 --- a/Demo/Base.lproj/Main.storyboard +++ b/Demo/Base.lproj/Main.storyboard @@ -4,9 +4,9 @@ - + @@ -23,11 +23,11 @@ + - + + + + diff --git a/Demo/ViewController.swift b/Demo/ViewController.swift index 6f2691f..b21f220 100644 --- a/Demo/ViewController.swift +++ b/Demo/ViewController.swift @@ -38,6 +38,17 @@ class ViewController: UIViewController { } } + @IBAction func logUserIdentifier() { + logStatusChange(string: "Log user identifier") + CurrentUser.sharedInstance.userIdentifier { userIdentifier, error in + if let userIdentifier = userIdentifier { + self.logStatusChange(string: "User identifier: \(userIdentifier)") + } else { + self.logStatusChange(string: "Unable to get user identifier") + } + } + } + @objc private func getUserStatus() { CurrentUser.sharedInstance.currentStatus { status in self.logStatusChange(status: status)