Trying to learn CoreStore 9.2.0 with Swift 5.10
After compilation errors I have attempted to back my @Field.Relationship
properties with the aliases and, at times, methods that are required to conform to FieldRelationshipType
. The conformance has not worked and there are also errors about inferring the generic parameter on my declaration of the inverse.
This is my trivial base case:
import Foundation
import CoreStore
class MICSelecta: CoreStoreObject {
@Field.Relationship("performances", inverse: \MICPerformance.$selecta)
var performances: Set<MICPerformance>
}
extension MICSelecta: FieldRelationshipToManyType {
typealias ObjectType = MICSelecta
typealias DestinationObjectType = MICPerformance
}
class MICPerformance: CoreStoreObject {
@Field.Relationship("selecta")
var selecta: MICSelecta
}
extension MICPerformance: FieldRelationshipToOneType {
typealias ObjectType = MICPerformance
typealias DestinationObjectType = MICSelecta
}
I've searched for examples on GitHub and haven't seen any explicit extensions such as these, which makes sense since the library might be able to reflect on these configurations as well as a bunch of others.
I've also attempted more thorough declarations with 4-5 aliases and 5 methods that can convert the entity to various formats such as NSManagedObject
.
Errors: on the line with the inverse declaration:
Generic parameter 'D' could not be inferred
Two errors on the Field.Relationship
line in MICPerformance
:
Generic struct 'Relationship' requires that 'MICSelecta' conform to 'FieldRelationshipType'
Referencing initializer 'init(_:deleteRule:versionHashModifier:previousVersionKeyPath:affectedByKeyPaths:)' on 'FieldContainer.Relationship' requires that 'MICSelecta' conform to 'FieldRelationshipToOneType'
I made var selecta: MICSelecta?
into an optional and it compiled