DynamicObject
public protocol DynamicObject : AnyObject
All CoreStore’s utilities are designed around DynamicObject instances. NSManagedObject and CoreStoreObject instances all conform to DynamicObject.
-
The object ID for this instance
Declaration
Swift
typealias ObjectID = NSManagedObjectID -
Used internally by CoreStore. Do not call directly.
Declaration
Swift
static func cs_forceCreate(entityDescription: NSEntityDescription, into context: NSManagedObjectContext, assignTo store: NSPersistentStore) -> Self -
Used internally by CoreStore. Do not call directly.
Declaration
Swift
static func cs_snapshotDictionary(id: ObjectID, context: NSManagedObjectContext) -> [String : Any]? -
Used internally by CoreStore. Do not call directly.
Declaration
Swift
static func cs_fromRaw(object: NSManagedObject) -> Self -
Used internally by CoreStore. Do not call directly.
Declaration
Swift
static func cs_matches(object: NSManagedObject) -> Bool -
Used internally by CoreStore. Do not call directly.
Declaration
Swift
func cs_toRaw() -> NSManagedObject -
Used internally by CoreStore. Do not call directly.
Declaration
Swift
func cs_id() -> ObjectID
-
partialObject()Extension methodReturns the
PartialObjectinstance for the object, which acts as a fast, type-safe KVC interface forCoreStoreObject.Declaration
Swift
public func partialObject() -> PartialObject<Self> -
FieldExtension methodThe containing type for value propertiess.
class Pet: CoreStoreObject { @Field.Stored("species") var species = "" @Field.Stored("nickname") var nickname: String? @Field.Coded("color", coder: FieldCoders.Plist.self) var eyeColor: UIColor? @Field.Relationship("owner", inverse: \.$pets) var owner: Person? @Field.Relationship("children") var children: Array<Pet> @Field.Relationship("parents", inverse: \.$children) var parents: Set<Pet> }Important
Fieldproperties are required to be used as@propertyWrappers. Any other declaration not using the@Field.*(...) varsyntax will result in undefined behavior.Declaration
Swift
public typealias Field = FieldContainer<Self>
-
asPublisher()Extension methodAn
ObjectPublisherwrapper for the exact same objectDeclaration
Swift
public func asPublisher() -> ObjectPublisher<Self>? -
asSnapshot()Extension methodA thread-safe
structthat is a full-copy of the object’s propertiesDeclaration
Swift
public func asSnapshot() -> ObjectSnapshot<Self>?
-
RelationshipExtension methodThe containing type for relationships.
Relationships can be anyCoreStoreObjectsubclass.class Dog: CoreStoreObject { let master = Relationship.ToOne<Person>("master") } class Person: CoreStoreObject { let pets = Relationship.ToManyUnordered<Dog>("pets", inverse: { $0.master }) }Important
Relationshipproperties are required to be stored properties. Computed properties will be ignored, includinglazyandweakproperties.Declaration
Swift
public typealias Relationship = RelationshipContainer<Self> -
TransformableExtension methodThe containing type for transformable properties.
Transformableproperties support types that conforms toNSCoding & NSCopying.class Animal: CoreStoreObject { let species = Value.Required<String>("species", initial: "") let nickname = Value.Optional<String>("nickname") let color = Transformable.Optional<UIColor>("color") }Important
Transformableproperties are required to be stored properties. Computed properties will be ignored, includinglazyandweakproperties.Declaration
Swift
public typealias Transformable = TransformableContainer<Self> -
ValueExtension methodThe containing type for value propertiess.
Valueproperties support any type that conforms toImportableAttributeType.class Animal: CoreStoreObject { let species = Value.Required<String>("species", initial: "") let nickname = Value.Optional<String>("nickname") let color = Transformable.Optional<UIColor>("color") }Important
Valueproperties are required to be stored properties. Computed properties will be ignored, includinglazyandweakproperties.Declaration
Swift
public typealias Value = ValueContainer<Self>
View on GitHub
DynamicObject Protocol Reference