Ditto
Ditto
is the entry point for accessing Ditto-related functionality.
-
An optional delegate that will be called with SDK lifecycle information if defined.
-
Configure a custom identifier for the current device.
When using
presence
, each remote peer is represented by a short UTF-8 “device name”. By default this will be a truncated version of the device’s hostname. It does not need to be unique among peers.Configure the device name before calling
startSync()
. If it is too long it may be truncated. -
The site ID that the instance of
Ditto
is using as part of its identity. -
The persistence directory used by Ditto to persist data.
-
The Ditto application ID.
-
A flag indicating whether or not the SDK has been activated with a valid license token.
-
A flag indicating whether or not sync is active. Use
startSync()
to active andstopSync()
to deactivate sync. -
Provides access to authentication information and methods for logging on to Ditto Cloud.
-
Provides visibility into to disk usage of this Ditto instance.
-
Provides access to the SDK’s store functionality.
-
-
The
DispatchQueue
that will be used to deliver delegate events. Defaults toDispatchQueue.main
. -
Assign a new transports configuration. By default peer-to-peer transports (Bluetooth, WiFi and AWDL) are enabled. You may use this property to alter the configuration at any time. Sync will not begin until
startSync()
is called. -
Convenience method to update the current transport config of the receiver.
Invokes the block with a copy of the current transport config which you can alter to your liking. The updated transport config is then set on the receiver.
You may use this method to alter the configuration at any time. Sync will not begin until
startSync
is invoked. -
Indicates whether or not history tracking is enabled. Default is
false
.History tracking is experimental and shouldn’t be used in production.
-
Initializes a new
Ditto
. -
Initializes a new
Ditto
. -
Activate an offline
DITDitto
instance by setting a license token. You cannot sync data across instances using an offline (Development, OfflinePlayground, Manual or SharedKey) identity before you have activated the associatedDitto
instance.Throws
DittoSwiftError
. -
Starts the network transports. Ditto will connect to other devices.
By default Ditto will enable all peer-to-peer transport types. On iOS this means Bluetooth, WiFi and AWDL. The network configuration can be customized using the
setTransportConfig
method.Throws
DittoSwiftError
. -
Stops all network transports.
You may continue to use the database locally but no data will sync to or from other devices.
-
Request bulk status information about the transports. This is mostly intended for statistical or debugging purposes.
Throws
DittoSwiftError
. -
A string identifying the version of the DittoSwift SDK.
-
Removes all sync metadata for any remote peers which aren’t currently connected. This method shouldn’t usually be called. Manually running garbage collection often will result in slower sync times. Ditto automatically runs a garbage a collection process in the background at optimal times.
Manually running garbage collection is typically only useful during testing if large amounts of data are being generated. Alternatively, if an entire data set is to be evicted and it’s clear that maintaining this metadata isn’t necessary, then garbage collection could be run after evicting the old data.
-
Explicitly opt-in to disabling the ability to sync with Ditto peers running any version of the SDK in the v3 series of releases.
Assuming this succeeds then this peer will only be able to sync with other peers using SDKs in the v4 (or higher) series of releases. Note that this disabling of sync spreads to peers that sync with a peer that has disabled, or has (transitively) had disabled, syncing with v3 SDK peers.
Throws
DittoSwiftError
if the operation fails.