Protocols

The following protocols are available globally.

  • The CSFetchClause implement clauses used to configure NSFetchRequests.

    See also

    FetchClause

    Declaration

    Swift

    @objc
    public protocol CSFetchClause
  • The CSQueryClause implement clauses used to configure NSFetchRequests.

    See also

    QueryClause

    Declaration

    Swift

    @objc
    public protocol CSQueryClause
  • The CSDeleteClause implement clauses used to configure NSFetchRequests.

    See also

    DeleteClause

    Declaration

    Swift

    @objc
    public protocol CSDeleteClause
  • Implement the CSListObserver protocol to observe changes to a list of NSManagedObjects. CSListObservers may register themselves to a CSListMonitor‘s -addListObserver: method:

    CSListMonitor *monitor = [CSCoreStore 
        monitorListFrom:[CSFrom entityClass:[MyPersonEntity class]]
        fetchClauses:@[[CSOrderBy sortDescriptor:[CSSortKey withKeyPath:@"lastName" ascending:YES]]]];
    [monitor addListObserver:self];
    

    See also

    ListObserver
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    @objc
    public protocol CSListObserver : AnyObject
  • Implement the CSListObjectObserver protocol to observe detailed changes to a list’s object. CSListObjectObservers may register themselves to a CSListMonitor‘s -addListObjectObserver(_:) method:

    CSListMonitor *monitor = [CSCoreStore
        monitorListFrom:[CSFrom entityClass:[MyPersonEntity class]]
        fetchClauses:@[[CSOrderBy sortDescriptor:[CSSortKey withKeyPath:@"lastName" ascending:YES]]]];
    [monitor addListObjectObserver:self];
    
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    @objc
    public protocol CSListObjectObserver : CSListObserver
  • Implement the CSListSectionObserver protocol to observe changes to a list’s section info. CSListSectionObservers may register themselves to a CSListMonitor‘s -addListSectionObserver: method:

    CSListMonitor *monitor = [CSCoreStore
        monitorSectionedListFrom:[CSFrom entityClass:[MyPersonEntity class]]
        sectionBy:[CSSectionBy keyPath:@"age"]
        fetchClauses:@[[CSOrderBy sortDescriptor:[CSSortKey withKeyPath:@"lastName" ascending:YES]]]];
    [monitor addListSectionObserver:self];
    
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    @objc
    public protocol CSListSectionObserver : CSListObjectObserver
  • Implement the CSObjectObserver protocol to observe changes to a single NSManagedObject instance. CSObjectObservers may register themselves to a CSObjectMonitor‘s -addObjectObserver: method:

    CSObjectMonitor *monitor = [CSCoreStore monitorObject:myObject];
    [monitor addObjectObserver:self];
    

    See also

    ObjectObserver
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    @objc
    public protocol CSObjectObserver : AnyObject
  • Objective-C Foundation types that are natively supported by Core Data managed attributes all conform to CoreDataNativeType.

    Declaration

    Swift

    @objc
    public protocol CoreDataNativeType : AnyObject, NSObjectProtocol
  • CoreStoreObjectiveCTypes are Objective-C accessible classes that represent CoreStore’s Swift types.

    See more

    Declaration

    Swift

    public protocol CoreStoreObjectiveCType : AnyObject
  • CoreStoreSwiftTypes are CoreStore’s Swift types that are bridgeable to Objective-C.

    See more

    Declaration

    Swift

    public protocol CoreStoreSwiftType
  • Custom loggers should implement the CoreStoreLogger protocol and pass its instance to CoreStore.logger. Calls to log(...), assert(...), and abort(...) are not tied to a specific queue/thread, so it is the implementer’s job to handle thread-safety.

    See more

    Declaration

    Swift

    public protocol CoreStoreLogger
  • Observation token for CoreStoreObject properties. Make sure to retain this instance to keep observing notifications.

    invalidate() will be called automatically when an CoreStoreObjectKeyValueObservation is deinited.

    See more

    Declaration

    Swift

    public protocol CoreStoreObjectKeyValueObservation : AnyObject
  • All CoreStore’s utilities are designed around DynamicObject instances. NSManagedObject and CoreStoreObject instances all conform to DynamicObject.

    See more

    Declaration

    Swift

    public protocol DynamicObject : AnyObject
  • Used only for utility methods.

    See more

    Declaration

    Swift

    public protocol DynamicKeyPath : AnyDynamicKeyPath
  • DynamicSchema are types that provide NSManagedObjectModel instances for a single model version. CoreStore currently supports the following concrete types:

    See more

    Declaration

    Swift

    public protocol DynamicSchema
  • Encapsulates containers which manages an internal NSManagedObjectContext, such as DataStacks and transactions, that can be used for fetching objects. CoreStore provides implementations for this protocol and should be used as a read-only abstraction.

    See more

    Declaration

    Swift

    public protocol FetchableSource : AnyObject
  • Types supported by CoreStore as NSManagedObject and CoreStoreObject property types. Supported default types:

  • Bool
  • CGFloat
  • Data
  • Date

    Date
  • Double
  • Float
  • Int
  • Int8
  • Int16
  • Int32
  • Int64
  • NSData
  • NSDate
  • NSDecimalNumber
  • NSNumber
  • NSString
  • NSURL
  • NSUUID
  • String
  • URL
  • UUID
  • In addition, RawRepresentable types whose RawValue already implements ImportableAttributeType only need to declare conformance to ImportableAttributeType.

    Declaration

    Swift

    public protocol ImportableAttributeType : QueryableAttributeType
  • NSManagedObject and CoreStoreObject subclasses that conform to the ImportableObject protocol can be imported from a specified ImportSource. This allows transactions to create and insert instances this way:

    class Person: NSManagedObject, ImportableObject {
        typealias ImportSource = NSDictionary
        // ...
    }
    
    CoreStore.perform(
        asynchronous: { (transaction) -> Void in
            let json: NSDictionary = // ...
            let person = try transaction.importObject(
                Into<Person>(),
                source: json
            )
            // ...
        },
        completion: { (result) in
            // ...
        }
    )
    
    See more

    Declaration

    Swift

    public protocol ImportableObject : DynamicObject
  • NSManagedObject subclasses that conform to the ImportableUniqueObject protocol can be imported from a specified ImportSource. This allows transactions to either update existing objects or create new instances this way:

    class Person: NSManagedObject, ImportableObject {
        typealias ImportSource = NSDictionary
        typealias UniqueIDType = NSString
        // ...
    }
    
    CoreStore.perform(
        asynchronous: { (transaction) -> Void in
            let json: NSDictionary = // ...
            let person = try transaction.importUniqueObject(
                Into<Person>(),
                source: json
            )
            // ...
        },
        completion: { (result) in
            // ...
        }
    )
    
    See more

    Declaration

    Swift

    public protocol ImportableUniqueObject : ImportableObject
  • Used only for utility methods. Types allowed as Value generic type to KeyPath utilities.

    Declaration

    Swift

    public protocol AllowedObjectiveCKeyPathValue
  • Implement the ListObserver protocol to observe changes to a list of NSManagedObjects. ListObservers may register themselves to a ListMonitor‘s addObserver(_:) method:

    let monitor = CoreStore.monitorList(
        From<Person>(),
        OrderBy(.ascending("lastName"))
    )
    monitor.addObserver(self)
    
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    public protocol ListObserver : AnyObject
  • Implement the ListObjectObserver protocol to observe detailed changes to a list’s object. ListObjectObservers may register themselves to a ListMonitor‘s addObserver(_:) method:

    let monitor = CoreStore.monitorList(
        From<MyPersonEntity>(),
        OrderBy(.ascending("lastName"))
    )
    monitor.addObserver(self)
    
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    public protocol ListObjectObserver : ListObserver
  • Implement the ListSectionObserver protocol to observe changes to a list’s section info. ListSectionObservers may register themselves to a ListMonitor‘s addObserver(_:) method:

    let monitor = CoreStore.monitorSectionedList(
        From<MyPersonEntity>(),
        SectionBy("age") { "Age \($0)" },
        OrderBy(.ascending("lastName"))
    )
    monitor.addObserver(self)
    
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    public protocol ListSectionObserver : ListObjectObserver
  • Implement the ObjectObserver protocol to observe changes to a single DynamicObject instance. ObjectObservers may register themselves to a ObjectMonitor‘s addObserver(_:) method:

    let monitor = CoreStore.monitorObject(object)
    monitor.addObserver(self)
    
    See more

    Declaration

    Swift

    @available(OSX 10.12, *)
    public protocol ObjectObserver : AnyObject
  • Types supported by CoreStore for querying, especially as generic type for Select clauses. Supported default types:

    • Bool
    • CGFloat
    • Data
    • Date
    • Double
    • Float
    • Int
    • Int8
    • Int16
    • Int32
    • Int64
    • NSData
    • NSDate
    • NSDecimalNumber
    • NSManagedObjectID
    • NSNull
    • NSNumber
    • NSString
    • NSURL
    • NSUUID
    • String
    • URL
    • UUID

    In addition, RawRepresentable types whose RawValue already implements QueryableAttributeType only need to declare conformance to QueryableAttributeType.

    See more

    Declaration

    Swift

    public protocol QueryableAttributeType : SelectResultType, Hashable
  • Encapsulates containers which manages an internal NSManagedObjectContext, such as DataStacks and transactions, that can be used for querying values. CoreStore provides implementations for this protocol and should be used as a read-only abstraction.

    See more

    Declaration

    Swift

    public protocol QueryableSource : AnyObject
  • The SelectResultType protocol is implemented by return types supported by the Select clause.

    Declaration

    Swift

    public protocol SelectResultType
  • The SelectAttributesResultType protocol is implemented by return types supported by the queryAttributes(...) methods.

    Declaration

    Swift

    public protocol SelectAttributesResultType : SelectResultType
  • The StorageInterface represents the data store managed (or to be managed) by the DataStack. When added to the DataStack, the StorageInterface serves as the interface for the NSPersistentStore. This may be a database file, an in-memory store, etc.

    See more

    Declaration

    Swift

    public protocol StorageInterface : AnyObject
  • The FetchClause implement clauses used to configure NSFetchRequests.

    Declaration

    Swift

    public protocol FetchClause
  • The QueryClause implement clauses used to configure NSFetchRequests.

    Declaration

    Swift

    public protocol QueryClause : FetchClause
  • The DeleteClause implement clauses used to configure NSFetchRequests.

    Declaration

    Swift

    public protocol DeleteClause : FetchClause
  • Used only for Where.Expression type constraints. Currently supports SingleTarget and CollectionTarget.

    Declaration

    Swift

    public protocol WhereExpressionTrait