SynchronizationManager
public class SynchronizationManager: PersistenceIntegration
Provides the ability to sync content from Contentful to a persistence store.
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
Instantiate a new SynchronizationManager.
Declaration
Swift
public init(client: Client? = nil, localizationScheme: LocalizationScheme, persistenceStore: PersistenceStore, persistenceModel: PersistenceModel)
Parameters
persistenceStore
The persistence store to use for storage
matching
An optional query for syncing specific content, see
Return Value
An initialised instance of SynchronizationManager
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
A wrapper method to synchronize data from Contentful to your local data store. The callback for this method is thread safe and will delegate to the thread that your data store is tied to.
Execute queries on your local data store in the callback for this method.
Declaration
Swift
public func sync(then completion: @escaping ResultsHandler<SyncSpace>)
-
The Contentful.Client that is configured to retrieve data from your Contentful space.
Declaration
Swift
public var client: Client?
-
The localization scheme with which to synchronize your Contentful space to your data store.
Declaration
Swift
public var localizationScheme: LocalizationScheme
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
This function is public as a side-effect of implementing
PersistenceDelegate
.Declaration
Swift
public func create(asset: Asset)
Parameters
asset
The newly created Asset
-
Never call this directly. This function is public as a side-effect of implementing
SyncSpaceDelegate
.Declaration
Swift
public func create(entry: Entry)
-
This function is public as a side-effect of implementing
PersistenceDelegate
.Declaration
Swift
public func delete(assetWithId: String)
Parameters
assetId
The ID of the deleted Asset
-
This function is public as a side-effect of implementing
SyncSpaceDelegate
.Declaration
Swift
public func delete(entryWithId: String)
Parameters
entryId
The ID of the deleted Entry
-
Undocumented
Declaration
Swift
public class SynchronizationManager: PersistenceIntegration
-
This method will seed a CoreData datastore from a directory of JSON files in the specified Bundle. Use this method in conjunction with the ContentfulBundleSync command line interface.
Throws
Errors if the media the files in the directory can’t be deserialized.
Declaration
Swift
public func seedDBFromJSONFiles(in directory: String, in bundle: Bundle) throws
Parameters
directory
The name of the directory in your bundle which contains your Contentful JSON and media assets generated by the CLI.
bundle
The bundle in which your directory containing your Contentful data is located.
-
Returns the local path for media assets that have been bundled in your app’s bundle for the passed in
Asset
orAssetPersistable
. This only works if you’ve used the ContentfulBundleSync command line tool.Declaration
Swift
public static func pathInBundle(for media: Media, inDirectoryNamed directory: String, in bundle: Bundle) -> String?
Parameters
media
The Asset or AssetPersistable for which on-disk data should be retreived.
directory
The name of the directory in your bundle which contains the media data
bundle
The bundle in which your directory containing your media files is located.
Return Value
The full string path for the underlying media file associated with the passed in
Asset
orAssetPersistabl
. Will returnnil
if no directory exists at your directory name, or if theMedia
does not have a validurlString
associated with it. -
Returns on-disk data that is bundled in your app’s bundle for the passed in
Asset
orAssetPersistable
. This only works if you’ve used the ContentfulBundleSync command line tool.Declaration
Swift
public static func bundledData(for media: Media, inDirectoryNamed directory: String, in bundle: Bundle) -> Data?
Parameters
media
The Asset or AssetPersistable for which on-disk data should be retreived.
directory
The name of the directory in your bundle which contains the media data
bundle
The bundle in which your directory containing your media files is located.
Return Value
The
Data
object for your media file. Will returnnil
if no directory exists at your directory name, or if theMedia
does not have aurlString
associated with it. -
Returns a file name to be used for local storage given a passed in
Asset
orAssetPersistable
.Declaration
Swift
public static func fileName(for media: Media) -> String?
Parameters
media
The Asset or AssetPersistable for which a file name should be computed.
Return Value
A filename for the underlying media file. Will return
nil
if the Asset or AssetPersistable does not have aurlString
associated with it. -
Errors thrown by ContentfulPersistence when trying to seed a database with bundled data.
See moreDeclaration
Swift
public enum DatabaseSeedingError: Swift.Error, CustomDebugStringConvertible