Skip to content

Instantly share code, notes, and snippets.

View dkasaj's full-sized avatar
💭
👨‍💻Coding

Daniel Kašaj dkasaj

💭
👨‍💻Coding
View GitHub Profile
@dkasaj
dkasaj / ServerChangeTokenCache.swift
Last active October 5, 2021 08:15
Class to handle CloudKit server change tokens
import CloudKit
final class ChangeTokenCache {
// MARK: - Zone support
/// Determines a unique UserDefaults key for storing zone change tokens
/// like from CKFetchRecordZoneChangesOperation
private static func userDefaultsKey(_ zoneID: CKRecordZone.ID) -> String {
return "token_" + zoneID.ownerName + zoneID.zoneName
// Bigger iPhones = any Max, any Plus, iPhone XR, iPhone 11
switch (UITraitCollection.current.horizontalSizeClass, UITraitCollection.current.verticalSizeClass) {
case (.compact, .compact):
// Smaller iPhones in landscape
case (.compact, .regular):
// iPhones in portrait
// iPads in portrait during any split screen,