Protocols

The following protocols are available globally.

CoreDataNativeType

  • Objective-C Foundation types that are natively supported by Core Data managed attributes all conform to CoreDataNativeType.

    Declaration

    Swift

    @objc
    public protocol CoreDataNativeType : NSObjectProtocol

CoreStoreLogger

  • Custom loggers should implement the CoreStoreLogger protocol and pass its instance to CoreStoreDefaults.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

CoreStoreObjectKeyValueObservation

  • 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

DynamicObject

  • 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

DiffableDataSource.Target

DynamicSchema

  • 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

FieldRelationshipType

FetchChainableBuilderType

FetchableSource

  • 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

FieldCoderType

  • Types that implement encoding to and decoding from Data to be used in Field.Coded properties’ coder: argument.

    class Person: CoreStoreObject {
    
        @Field.Coded("profile", coder: FieldCoders.Json.self)
        var profile: Profile = .init()
    }
    
    See more

    Declaration

    Swift

    public protocol FieldCoderType

DefaultNSSecureCodable

FieldOptionalType

  • Optional values to be used for Field properties.

    See more

    Declaration

    Swift

    public protocol FieldOptionalType : ExpressibleByNilLiteral

FieldStorableType

  • Values to be used for Field.Stored properties.

    See more

    Declaration

    Swift

    public protocol FieldStorableType

GroupByClause

ImportableAttributeType

  • 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

ImportableObject

  • 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
        // ...
    }
    
    dataStack.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

ImportableUniqueObject

  • 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
        // ...
    }
    
    dataStack.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, Hashable

AllowedObjectiveCKeyPathValue

  • Used only for utility methods. Types allowed as Value generic type to KeyPath utilities.

    See more

    Declaration

    Swift

    public protocol AllowedObjectiveCKeyPathValue

AllowedOptionalObjectiveCKeyPathValue

AllowedObjectiveCAttributeKeyPathValue

AllowedObjectiveCRelationshipKeyPathValue

AllowedObjectiveCToManyRelationshipKeyPathValue

KeyPathStringConvertible

AttributeKeyPathStringConvertible

RelationshipKeyPathStringConvertible

ToManyRelationshipKeyPathStringConvertible

ListObserver

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

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

    Declaration

    Swift

    public protocol ListObserver : AnyObject

ListObjectObserver

  • 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 = dataStack.monitorList(
        From<MyPersonEntity>(),
        OrderBy(.ascending("lastName"))
    )
    monitor.addObserver(self)
    
    See more

    Declaration

    Swift

    public protocol ListObjectObserver : ListObserver

ListSectionObserver

  • 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 = dataStack.monitorSectionedList(
        From<MyPersonEntity>(),
        SectionBy("age") { "Age \($0)" },
        OrderBy(.ascending("lastName"))
    )
    monitor.addObserver(self)
    
    See more

    Declaration

    Swift

    public protocol ListSectionObserver : ListObjectObserver

ObjectObserver

  • Implement the ObjectObserver protocol to observe changes to a single DynamicObject instance. ObjectObservers may register themselves to an ObjectMonitor‘s addObserver(_:) method:

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

    Declaration

    Swift

    public protocol ObjectObserver : AnyObject

AnyObjectRepresentation

OrderByClause

QueryChainableBuilderType

QueryableAttributeType

  • 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

QueryableSource

  • 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

SchemaMappingProvider

SectionMonitorBuilderType

SelectResultType

  • The SelectResultType protocol is implemented by return types supported by the Select clause.

    Declaration

    Swift

    public protocol SelectResultType

SelectAttributesResultType

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

    Declaration

    Swift

    public protocol SelectAttributesResultType : SelectResultType

SelectClause

StorageInterface

  • 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

LocalStorage

FetchClause

  • The FetchClause implement clauses used to configure NSFetchRequests.

    Declaration

    Swift

    public protocol FetchClause

QueryClause

  • The QueryClause implement clauses used to configure NSFetchRequests.

    Declaration

    Swift

    public protocol QueryClause : FetchClause

DeleteClause

  • The DeleteClause implement clauses used to configure NSFetchRequests.

    Declaration

    Swift

    public protocol DeleteClause : FetchClause

AnyWhereClause

WhereExpressionTrait

  • Used only for Where.Expression type constraints. Currently supports SingleTarget and CollectionTarget.

    Declaration

    Swift

    public protocol WhereExpressionTrait

WhereClauseType