Protocols
The following protocols are available globally.
-
Objective-C Foundation types that are natively supported by Core Data managed attributes all conform to
CoreDataNativeType
.Declaration
Swift
@objc public protocol CoreDataNativeType : NSObjectProtocol
-
Custom loggers should implement the
See moreCoreStoreLogger
protocol and pass its instance toCoreStoreDefaults.logger
. Calls tolog(...)
,assert(...)
, andabort(...)
are not tied to a specific queue/thread, so it is the implementer’s job to handle thread-safety.Declaration
Swift
public protocol CoreStoreLogger
-
Observation token for
CoreStoreObject
properties. Make sure to retain this instance to keep observing notifications.
See moreinvalidate()
will be called automatically when anCoreStoreObjectKeyValueObservation
is deinited.Declaration
Swift
public protocol CoreStoreObjectKeyValueObservation : AnyObject
-
All CoreStore’s utilities are designed around
See moreDynamicObject
instances.NSManagedObject
andCoreStoreObject
instances all conform toDynamicObject
.Declaration
Swift
public protocol DynamicObject : AnyObject
-
The
See moreDiffableDataSource.Target
protocol allows custom views to consumeListSnapshot
diffable data similar to howDiffableDataSource.TableViewAdapter
andDiffableDataSource.CollectionViewAdapter
reloads data for their corresponding views.Declaration
Swift
public protocol DiffableDataSourceTarget
-
DynamicSchema
are types that provideNSManagedObjectModel
instances for a single model version. CoreStore currently supports the following concrete types:XcodeDataModelSchema
: describes models loaded from a .xcdatamodeld file.UnsafeDataModelSchema
: describes models loaded directly from an existingNSManagedObjectModel
. It is not advisable to continue using this model as its metadata are not available to CoreStore.CoreStoreSchema
: describes models written forCoreStoreObject
Swift class declarations.
Declaration
Swift
public protocol DynamicSchema
-
Values to be used for
See moreField.Relationship
properties.Declaration
Swift
public protocol FieldRelationshipType
-
Utility protocol for
See moreFetchChainBuilder
. Used in fetch methods that support chained fetch builders.Declaration
Swift
public protocol FetchChainableBuilderType
-
Encapsulates containers which manages an internal
See moreNSManagedObjectContext
, such asDataStack
s and transactions, that can be used for fetching objects. CoreStore provides implementations for this protocol and should be used as a read-only abstraction.Declaration
Swift
public protocol FetchableSource : AnyObject
-
Types that implement encoding to and decoding from
Data
to be used inField.Coded
properties’coder:
argument.
See moreclass Person: CoreStoreObject { @Field.Coded("profile", coder: FieldCoders.Json.self) var profile: Profile = .init() }
Declaration
Swift
public protocol FieldCoderType
-
Types that are supported by
FieldCoders.DefaultNSSecureCoding
Declaration
Swift
public protocol DefaultNSSecureCodable : NSObject, NSSecureCoding
-
Optional values to be used for
See moreField
properties.Declaration
Swift
public protocol FieldOptionalType : ExpressibleByNilLiteral
-
Values to be used for
See moreField.Stored
properties.Declaration
Swift
public protocol FieldStorableType
-
Types supported by CoreStore as
NSManagedObject
andCoreStoreObject
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 whoseRawValue
already implementsImportableAttributeType
only need to declare conformance toImportableAttributeType
.Declaration
Swift
public protocol ImportableAttributeType : QueryableAttributeType
-
NSManagedObject
andCoreStoreObject
subclasses that conform to theImportableObject
protocol can be imported from a specifiedImportSource
. This allows transactions to create and insert instances this way:
See moreclass 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 // ... } )
Declaration
Swift
public protocol ImportableObject : DynamicObject
-
NSManagedObject
subclasses that conform to theImportableUniqueObject
protocol can be imported from a specifiedImportSource
. This allows transactions to either update existing objects or create new instances this way:
See moreclass 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 // ... } )
Declaration
Swift
public protocol ImportableUniqueObject : ImportableObject, Hashable
-
Used only for utility methods. Types allowed as
See moreValue
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Value
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedOptionalObjectiveCKeyPathValue : AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
See moreValue
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCAttributeKeyPathValue : AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Value
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCRelationshipKeyPathValue : AllowedOptionalObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Value
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCToManyRelationshipKeyPathValue : AllowedOptionalObjectiveCKeyPathValue
-
Used only for utility methods.
See moreDeclaration
Swift
public protocol KeyPathStringConvertible : AnyKeyPathStringConvertible
-
Used only for utility methods.
See moreDeclaration
Swift
public protocol AttributeKeyPathStringConvertible : KeyPathStringConvertible
-
Used only for utility methods.
See moreDeclaration
Swift
public protocol RelationshipKeyPathStringConvertible : KeyPathStringConvertible
-
Used only for utility methods.
Declaration
Swift
public protocol ToManyRelationshipKeyPathStringConvertible : RelationshipKeyPathStringConvertible where Self.ReturnValueType : Sequence
-
Implement the
ListObserver
protocol to observe changes to a list ofNSManagedObject
s.ListObserver
s may register themselves to aListMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorList( From<Person>(), OrderBy(.ascending("lastName")) ) monitor.addObserver(self)
Declaration
Swift
public protocol ListObserver : AnyObject
-
Implement the
ListObjectObserver
protocol to observe detailed changes to a list’s object.ListObjectObserver
s may register themselves to aListMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorList( From<MyPersonEntity>(), OrderBy(.ascending("lastName")) ) monitor.addObserver(self)
Declaration
Swift
public protocol ListObjectObserver : ListObserver
-
Implement the
ListSectionObserver
protocol to observe changes to a list’s section info.ListSectionObserver
s may register themselves to aListMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorSectionedList( From<MyPersonEntity>(), SectionBy("age") { "Age \($0)" }, OrderBy(.ascending("lastName")) ) monitor.addObserver(self)
Declaration
Swift
public protocol ListSectionObserver : ListObjectObserver
-
Implement the
ObjectObserver
protocol to observe changes to a singleDynamicObject
instance.ObjectObserver
s may register themselves to anObjectMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorObject(object) monitor.addObserver(self)
Declaration
Swift
public protocol ObjectObserver : AnyObject
-
Used internally by CoreStore. Do not conform to directly.
See moreDeclaration
Swift
public protocol AnyObjectRepresentation
-
An object that acts as interfaces for
See moreCoreStoreObject
s orNSManagedObject
sDeclaration
Swift
public protocol ObjectRepresentation : AnyObjectRepresentation
-
Utility protocol for
See moreQueryChainBuilder
. Used in fetch methods that support chained query builders.Declaration
Swift
public protocol QueryChainableBuilderType
-
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,
See moreRawRepresentable
types whoseRawValue
already implementsQueryableAttributeType
only need to declare conformance toQueryableAttributeType
.Declaration
Swift
public protocol QueryableAttributeType : SelectResultType, Hashable
-
Encapsulates containers which manages an internal
See moreNSManagedObjectContext
, such asDataStack
s and transactions, that can be used for querying values. CoreStore provides implementations for this protocol and should be used as a read-only abstraction.Declaration
Swift
public protocol QueryableSource : AnyObject
-
The
See moreSchemaMappingProvider
provides migration mapping information between twoDynamicSchema
versions.Declaration
Swift
public protocol SchemaMappingProvider
-
Utility protocol for
See moreSectionMonitorChainBuilder
. Used in methods that support chained fetch builders.Declaration
Swift
public protocol SectionMonitorBuilderType
-
The
SelectResultType
protocol is implemented by return types supported by theSelect
clause.Declaration
Swift
public protocol SelectResultType
-
The
SelectAttributesResultType
protocol is implemented by return types supported by thequeryAttributes(...)
methods.Declaration
Swift
public protocol SelectAttributesResultType : SelectResultType
-
The
See moreStorageInterface
represents the data store managed (or to be managed) by theDataStack
. When added to theDataStack
, theStorageInterface
serves as the interface for theNSPersistentStore
. This may be a database file, an in-memory store, etc.Declaration
Swift
public protocol StorageInterface : AnyObject
-
The
See moreLocalStorage
representsStorageInterface
s that are backed by local files.Declaration
Swift
public protocol LocalStorage : StorageInterface
-
The
FetchClause
implement clauses used to configureNSFetchRequest
s.Declaration
Swift
public protocol FetchClause
-
The
QueryClause
implement clauses used to configureNSFetchRequest
s.Declaration
Swift
public protocol QueryClause : FetchClause
-
The
DeleteClause
implement clauses used to configureNSFetchRequest
s.Declaration
Swift
public protocol DeleteClause : FetchClause
-
Declaration
Swift
public protocol AnyWhereClause : DeleteClause, QueryClause
-
Used only for
Where.Expression
type constraints. Currently supportsSingleTarget
andCollectionTarget
.Declaration
Swift
public protocol WhereExpressionTrait
-
Abstracts the
See moreWhere
clause for protocol utilities. Typically used only for utility method generic constraints.Declaration
Swift
public protocol WhereClauseType : AnyWhereClause