CoreDataStore
public class CoreDataStore : PersistenceStore
Implementation fo the PersistenceStore protocol using CoreData
-
Initialize a new CoreData persistence store
Declaration
Swift
public init(context: NSManagedObjectContext)Parameters
contextThe managed object context used for querying and
Return Value
An initialised instance of this class
-
Undocumented
Declaration
Swift
public func fetchRequest(for type: Any.Type, predicate: NSPredicate) throws -> NSFetchRequest<NSFetchRequestResult>
-
Create a new object of the given type.
Throws
If a invalid type was specified
Declaration
Swift
public func create<T>(type: Any.Type) throws -> TParameters
typeThe type of which a new object should be created
Return Value
A newly created object of the given type
-
Delete objects of the given type which also match the predicate.
Throws
If an invalid type was specified
Declaration
Swift
public func delete(type: Any.Type, predicate: NSPredicate) throwsParameters
typeThe type of which objects should be deleted
predicateThe predicate used for matching objects to delete
-
Fetches all objects of a specific type which also match the predicate.
Throws
If an invalid type was specified
Declaration
Swift
public func fetchAll<T>(type: Any.Type, predicate: NSPredicate) throws -> [T]Parameters
typeThe type of which objects should be fetched
predicateThe predicate used for matching object to fetch
Return Value
An array of matching objects
-
Declaration
Swift
public func fetchOne<T>( type: Any.Type, predicate: NSPredicate ) throws -> T -
Returns an array of names of properties the given type stores persistently.
This should omit any properties returned by
relationshipsFor(type:).Throws
If an invalid type was specified
Declaration
Swift
public func properties(for type: Any.Type) throws -> [String]Parameters
typeThe type of which properties should be returned for
Return Value
An array of property names representing system native types.
-
Returns an array of property names for any relationship the given type stores persistently.
Throws
If an invalid type was specified
Declaration
Swift
public func relationships(for type: Any.Type) throws -> [String]Parameters
typeThe type of which properties should be returned for
Return Value
An array of property names representing related entities.
-
Performs the actual save to the persistence store.
Throws
If any error occured during the save operationDeclaration
Swift
public func save() throws -
Remove persistence store and add a new one in its place WARNING: all the data will be wipes in the current persistence store associated with the NSManagedObjectContext
Declaration
Swift
public func wipe() throws
-
Undocumented
Declaration
Swift
public func performBlock(block: @escaping () -> Void) -
Undocumented
Declaration
Swift
public func performAndWait(block: @escaping () -> Void) -
Before swapping: delete WAL/SHM side-cars and remove only the store matching
storeFileURL.Declaration
Swift
public func onStorePreseedingWillBegin(at storeFileURL: URL) throws -
After swapping: add the store back and then reset the context.
Declaration
Swift
public func onStorePreseedingCompleted(at seededFileURL: URL) throws
View on GitHub
CoreDataStore Class Reference