Tokens
open class Tokens: NSObject, NSCoding
CloudCore’s class for storing global CKToken objects. Framework uses one to upload or download only changed data (smart-sync).
To detect what data is new and old, framework uses CloudKit’s CKToken objects and it is needed to be loaded every time application launches and saved on exit.
Framework stores tokens in 2 places:
- singleton
Tokensobject inCloudCore.tokens - tokens per record inside Record Data attribute, it is managed automatically you don’t need to take any actions about that token
You need to save Tokens object before application terminates otherwise you will loose smart-sync ability.
Example
func applicationWillTerminate(_ application: UIApplication) {
CloudCore.tokens.saveToUserDefaults()
}
-
Create fresh object without any Tokens inside. Can be used to fetch full data.
Declaration
Swift
public override init()
-
Load saved Tokens from UserDefaults. Key is used from
CloudCoreConfig.userDefaultsKeyTokensDeclaration
Swift
open static func loadFromUserDefaults() -> TokensReturn Value
previously saved
Tokenobject, if tokens weren’t saved before newly initializedTokensobject will be returned -
Save tokens to UserDefaults and synchronize. Key is used from
CloudCoreConfig.userDefaultsKeyTokensDeclaration
Swift
open func saveToUserDefaults()
-
Returns an object initialized from data in a given unarchiver.
Declaration
Swift
public required init?(coder aDecoder: NSCoder) -
Encodes the receiver using a given archiver.
Declaration
Swift
open func encode(with aCoder: NSCoder)
Tokens Class Reference