FieldContainer
public enum FieldContainer<O> where O : CoreStoreObject
The containing type for value properties. Use the Field typealias instead for shorter syntax.
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>
}
-
The containing type for stored property values. Any type that conforms to
FieldStorableTypeare supported.class Person: CoreStoreObject { @Field.Stored("title") var title: String = "Mr." @Field.Stored("nickname") var nickname: String? }See moreImportant
Fieldproperties are required to be used as@propertyWrappers. Any other declaration not using the@Field.Stored(...) varsyntax will be ignored.Declaration
Swift
@propertyWrapper public struct Stored<V> : AttributeKeyPathStringConvertible, FieldAttributeProtocol where V : FieldStorableType
-
The containing type for stored property values. Any type supported by the specified encoder/decoder are allowed.
class Animal: CoreStoreObject { @Field.Coded("eyeColor", coder: FieldCoders.NSCoding.self) var eyeColor: UIColor = .black @Field.Coded( "bloodType", coder: { encode: { $0.toData() }, decode: { BloodType(fromData: $0) } } ) var bloodType: BloodType = .unknown }See moreImportant
Fieldproperties are required to be used as@propertyWrappers. Any other declaration not using the@Field.Stored(...) varsyntax will be ignored.Declaration
Swift
@propertyWrapper public struct Coded<V> : AttributeKeyPathStringConvertible, FieldAttributeProtocol
-
The containing type for relationships. Any
CoreStoreObjectsubclass can be a destination type. Inverse relationships should be declared from the destination type as well, using theinverse:argument for the relationship.class Dog: CoreStoreObject { @Field.Relationship("master") var master: Person? } class Person: CoreStoreObject { @Field.Relationship("pets", inverse: \.$master) var pets: Set<Dog> }See moreImportant
Fieldproperties are required to be used as@propertyWrappers. Any other declaration not using the@Field.Relationship(...) varsyntax will be ignored.Declaration
Swift
@propertyWrapper public struct Relationship<V> : RelationshipKeyPathStringConvertible, FieldRelationshipProtocol where V : FieldRelationshipTypeextension FieldContainer.Relationship: ToManyRelationshipKeyPathStringConvertible where V: FieldRelationshipToManyType
-
The containing type for computed property values. Because this value is not persisted to the backing store, any type is supported.
Field.Virtualproperties are not allowed to have initial values, includingnilfor optional types.class Animal: CoreStoreObject { @Field.Virtual( "pluralName", customGetter: { (object, field) in return object.$species.value + "s" } ) var pluralName: String @Field.Stored("species") var species: String = "" }See moreImportant
Fieldproperties are required to be used as@propertyWrappers. Any other declaration not using the@Field.Virtual(...) varsyntax will be ignored.Declaration
Swift
@propertyWrapper public struct Virtual<V> : AttributeKeyPathStringConvertible, FieldAttributeProtocol
View on GitHub
FieldContainer Enumeration Reference