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 Tokens object in CloudCore.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()
  • 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)