SynchronizationManager

public class SynchronizationManager: PersistenceIntegration

Provides the ability to sync content from Contentful to a persistence store.

  • 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 or AssetPersistable. 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 or AssetPersistabl. Will return nil if no directory exists at your directory name, or if the Media does not have a valid urlString associated with it.

  • Returns on-disk data that is bundled in your app’s bundle for the passed in Asset or AssetPersistable. 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 return nil if no directory exists at your directory name, or if the Media does not have a urlString associated with it.

  • Returns a file name to be used for local storage given a passed in Asset or AssetPersistable.

    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 a urlString associated with it.

  • Errors thrown by ContentfulPersistence when trying to seed a database with bundled data.

    See more

    Declaration

    Swift

    public enum DatabaseSeedingError: Swift.Error, CustomDebugStringConvertible