CoreDataStackProvider

public struct CoreDataStackProvider
extension CoreDataStackProvider: Equatable

An instance of CoreDataStackProvider is responsible for creating instances of CoreDataStack.

Because the adding of the persistent store to the persistent store coordinator during initialization of a CoreDataStack can take an unknown amount of time, you should not perform this operation on the main queue.

See this guide for more details.

Warning

You should not create instances of CoreDataStack directly. Use a CoreDataStackProvider instead.

Typealiases

  • Describes the initialization options for a persistent store.

    Declaration

    Swift

    public typealias PersistentStoreOptions = [AnyHashable : Any]

Properties

  • Describes default persistent store options.

    Declaration

    Swift

    public static let defaultStoreOptions: PersistentStoreOptions
  • The model for the stack that the factory produces.

    Declaration

    Swift

    public let model: CoreDataModel
  • A dictionary that specifies options for the store that the factory produces. The default value is DefaultStoreOptions.

    Declaration

    Swift

    public let options: PersistentStoreOptions?

Initialization

Creating a stack

  • Initializes a new CoreDataStack instance using the factory’s model and options.

    Warning

    If a queue is provided, this operation is performed asynchronously on the specified queue, and the completion closure is executed asynchronously on the main queue. If queue is nil, then this method and the completion closure execute synchronously on the current queue.

    Declaration

    Swift

    public func createStack(onQueue queue: DispatchQueue? = .global(qos: .userInitiated),
                            completion: @escaping (CoreDataStack.StackResult) -> Void)

    Parameters

    queue

    The queue on which to initialize the stack. The default is a background queue with a “user initiated” quality of service class. If passing nil, this method is executed synchronously on the queue from which the method was called.

    completion

    The closure to be called once initialization is complete. If a queue is provided, this is called asynchronously on the main queue. Otherwise, this is executed on the thread from which the method was originally called.