Skip to main content

CoreDataStack

Encapsulates a Core Data stack. This predates NSPersistentContainer and it's basically the same.

@objc public class CoreDataStack: NSObject 

Inheritance#

NSObject

Initializers#

init(storeType:model:storeURL:concurrencyType:dispatchImmediately:)#

Create a new Core Data stack.

@objc public init(storeType: String,         model: NSManagedObjectModel,         storeURL: URL?,         concurrencyType: NSManagedObjectContextConcurrencyType = .privateQueueConcurrencyType,         dispatchImmediately: Bool = false) 

Parameters#

  • storeType: Store type, such as NSSQLiteStoreType.
  • model: model to be used for the stack.
  • storeURL: URL for the store location. Optional.
  • concurrencyType: Default is privateQueueConcurrencyType
  • dispatchImmediately: Used for testing.

Properties#

managedObjectContext#

@objc public private(set) var managedObjectContext: NSManagedObjectContext!

persistentStoreCoordinator#

@objc public private(set) var persistentStoreCoordinator: NSPersistentStoreCoordinator!

store#

@objc public private(set) var store: NSPersistentStore!

storeType#

@objc public let storeType: String

storeURL#

@objc public let storeURL: URL?

useDispatchImmediately#

@objc public let useDispatchImmediately: Bool

model#

@objc public let model: NSManagedObjectModel

concurrencyType#

@objc public let concurrencyType: NSManagedObjectContextConcurrencyType

Methods#

deleteStore()#

Winds down the stack and deletes the store.

@objc public func deleteStore()