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 moreCoreStoreLoggerprotocol 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
CoreStoreObjectproperties. Make sure to retain this instance to keep observing notifications.
See moreinvalidate()will be called automatically when anCoreStoreObjectKeyValueObservationis deinited.Declaration
Swift
public protocol CoreStoreObjectKeyValueObservation : AnyObject
-
All CoreStore’s utilities are designed around
See moreDynamicObjectinstances.NSManagedObjectandCoreStoreObjectinstances all conform toDynamicObject.Declaration
Swift
public protocol DynamicObject : AnyObject
-
The
See moreDiffableDataSource.Targetprotocol allows custom views to consumeListSnapshotdiffable data similar to howDiffableDataSource.TableViewAdapterandDiffableDataSource.CollectionViewAdapterreloads data for their corresponding views.Declaration
Swift
public protocol DiffableDataSourceTarget
-
DynamicSchemaare types that provideNSManagedObjectModelinstances 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 forCoreStoreObjectSwift class declarations.
Declaration
Swift
public protocol DynamicSchema
-
Values to be used for
See moreField.Relationshipproperties.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 asDataStacks 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
Datato be used inField.Codedproperties’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.DefaultNSSecureCodingDeclaration
Swift
public protocol DefaultNSSecureCodable : NSObject, NSSecureCoding
-
Optional values to be used for
See moreFieldproperties.Declaration
Swift
public protocol FieldOptionalType : ExpressibleByNilLiteral
-
Values to be used for
See moreField.Storedproperties.Declaration
Swift
public protocol FieldStorableType
-
Types supported by CoreStore as
NSManagedObjectandCoreStoreObjectproperty 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,
RawRepresentabletypes whoseRawValuealready implementsImportableAttributeTypeonly need to declare conformance toImportableAttributeType.Declaration
Swift
public protocol ImportableAttributeType : QueryableAttributeType
-
NSManagedObjectandCoreStoreObjectsubclasses that conform to theImportableObjectprotocol 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
-
NSManagedObjectsubclasses that conform to theImportableUniqueObjectprotocol 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 moreValuegeneric type toKeyPathutilities.Declaration
Swift
public protocol AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Valuegeneric type toKeyPathutilities.Declaration
Swift
public protocol AllowedOptionalObjectiveCKeyPathValue : AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
See moreValuegeneric type toKeyPathutilities.Declaration
Swift
public protocol AllowedObjectiveCAttributeKeyPathValue : AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Valuegeneric type toKeyPathutilities.Declaration
Swift
public protocol AllowedObjectiveCRelationshipKeyPathValue : AllowedOptionalObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Valuegeneric type toKeyPathutilities.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
ListObserverprotocol to observe changes to a list ofNSManagedObjects.ListObservers 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
ListObjectObserverprotocol to observe detailed changes to a list’s object.ListObjectObservers 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
ListSectionObserverprotocol to observe changes to a list’s section info.ListSectionObservers 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
ObjectObserverprotocol to observe changes to a singleDynamicObjectinstance.ObjectObservers 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 moreCoreStoreObjects orNSManagedObjectsDeclaration
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
Selectclauses. Supported default types:BoolCGFloatDataDateDoubleFloatIntInt8Int16Int32Int64NSDataNSDateNSDecimalNumberNSManagedObjectIDNSNullNSNumberNSStringNSURLNSUUIDStringURLUUID
In addition,
See moreRawRepresentabletypes whoseRawValuealready implementsQueryableAttributeTypeonly need to declare conformance toQueryableAttributeType.Declaration
Swift
public protocol QueryableAttributeType : SelectResultType, Hashable
-
Encapsulates containers which manages an internal
See moreNSManagedObjectContext, such asDataStacks 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 moreSchemaMappingProviderprovides migration mapping information between twoDynamicSchemaversions.Declaration
Swift
public protocol SchemaMappingProvider
-
Utility protocol for
See moreSectionMonitorChainBuilder. Used in methods that support chained fetch builders.Declaration
Swift
public protocol SectionMonitorBuilderType
-
The
SelectResultTypeprotocol is implemented by return types supported by theSelectclause.Declaration
Swift
public protocol SelectResultType
-
The
SelectAttributesResultTypeprotocol is implemented by return types supported by thequeryAttributes(...)methods.Declaration
Swift
public protocol SelectAttributesResultType : SelectResultType
-
The
See moreStorageInterfacerepresents the data store managed (or to be managed) by theDataStack. When added to theDataStack, theStorageInterfaceserves as the interface for theNSPersistentStore. This may be a database file, an in-memory store, etc.Declaration
Swift
public protocol StorageInterface : AnyObject
-
The
See moreLocalStoragerepresentsStorageInterfaces that are backed by local files.Declaration
Swift
public protocol LocalStorage : StorageInterface
-
The
FetchClauseimplement clauses used to configureNSFetchRequests.Declaration
Swift
public protocol FetchClause
-
The
QueryClauseimplement clauses used to configureNSFetchRequests.Declaration
Swift
public protocol QueryClause : FetchClause
-
The
DeleteClauseimplement clauses used to configureNSFetchRequests.Declaration
Swift
public protocol DeleteClause : FetchClause
-
Declaration
Swift
public protocol AnyWhereClause : DeleteClause, QueryClause
-
Used only for
Where.Expressiontype constraints. Currently supportsSingleTargetandCollectionTarget.Declaration
Swift
public protocol WhereExpressionTrait
-
Abstracts the
See moreWhereclause for protocol utilities. Typically used only for utility method generic constraints.Declaration
Swift
public protocol WhereClauseType : AnyWhereClause
View on GitHub
Protocols Reference