RelationshipContainer
public enum RelationshipContainer<O> where O : CoreStoreObject
The containing type for relationships. Use the DynamicObject.Relationship
typealias instead for shorter syntax.
class Dog: CoreStoreObject {
let master = Relationship.ToOne<Person>("master")
}
class Person: CoreStoreObject {
let pets = Relationship.ToManyUnordered<Dog>("pets", inverse: { $0.master })
}
-
These constants define what happens to relationships when an object is deleted.
Declaration
Swift
public enum DeleteRule
-
The containing type for to-one relationships. Any
CoreStoreObject
subclass 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 { let master = Relationship.ToOne<Person>("master") } class Person: CoreStoreObject { let pets = Relationship.ToManyUnordered<Dog>("pets", inverse: { $0.master }) }
Important
Relationship.ToOne
properties are required to be stored properties. Computed properties will be ignored, includinglazy
andweak
properties.Declaration
Swift
public final class ToOne<D> : RelationshipKeyPathStringConvertible, RelationshipProtocol where D : CoreStoreObject
-
The containing type for to-many unordered relationships. Any
CoreStoreObject
subclass 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 { let master = Relationship.ToOne<Person>("master") } class Person: CoreStoreObject { let pets = Relationship.ToManyUnordered<Dog>("pets", inverse: { $0.master }) }
Important
Relationship.ToManyUnordered
properties are required to be stored properties. Computed properties will be ignored, includinglazy
andweak
properties.Declaration
Swift
public final class ToManyUnordered<D> : ToManyRelationshipKeyPathStringConvertible, RelationshipProtocol where D : CoreStoreObject
extension RelationshipContainer.ToManyUnordered: Sequence
-
The containing type for to-many ordered relationships. Any
CoreStoreObject
subclass 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 { let master = Relationship.ToOne<Person>("master") } class Person: CoreStoreObject { let pets = Relationship.ToManyOrdered<Dog>("pets", inverse: { $0.master }) }
Important
Relationship.ToManyOrdered
properties are required to be stored properties. Computed properties will be ignored, includinglazy
andweak
properties.Declaration
Swift
public final class ToManyOrdered<D> : ToManyRelationshipKeyPathStringConvertible, RelationshipProtocol where D : CoreStoreObject
extension RelationshipContainer.ToManyOrdered: RandomAccessCollection