mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-09 16:48:45 +01:00
42 lines
977 B
Swift
42 lines
977 B
Swift
//
|
|
// CKContainer+Extensions.swift
|
|
// Account
|
|
//
|
|
// Created by Maurice Parker on 4/4/20.
|
|
// Copyright © 2020 Ranchero Software, LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import CloudKit
|
|
|
|
extension CKContainer {
|
|
|
|
private static let userRecordIDKey = "cloudkit.server.userRecordID"
|
|
|
|
var userRecordID: String? {
|
|
get {
|
|
return UserDefaults.standard.string(forKey: Self.userRecordIDKey)
|
|
}
|
|
set {
|
|
guard let userRecordID = newValue else {
|
|
UserDefaults.standard.removeObject(forKey: Self.userRecordIDKey)
|
|
return
|
|
}
|
|
UserDefaults.standard.set(userRecordID, forKey: Self.userRecordIDKey)
|
|
}
|
|
}
|
|
|
|
func fetchUserRecordID() {
|
|
guard userRecordID == nil else { return }
|
|
fetchUserRecordID { recordID, error in
|
|
guard let recordID = recordID, error == nil else {
|
|
return
|
|
}
|
|
DispatchQueue.main.async {
|
|
self.userRecordID = recordID.recordName
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|