0 Replies
      Latest reply on Sep 22, 2019 6:15 PM by mprogers
      mprogers Level 1 Level 1 (0 points)

        I am trying to design a 1-many relationship between Advisors and Students in CloudKit. My problem is that in my model classes, I need Student to be able to refer to a Teacher -- so I have a teacher property of type Teacher. But in CloudKit, to establish the relationship, I need a CKRecord.Reference. So now I have two properties, each of which is relevant in different contexts.


        Is there some standard way of doing this? I'm used to Backendless, that hides most of this detail, but I'd like to try Apple's approach so I don't need to worry about user management.


        Thanks for any info ...


        class Teacher : Equatable, CKRecordValueProtocol {
            var id: Int
            var lastName: String
            var firstName: String
            var students: [Student]
           // other stuff omitted
        class Student : Equatable {
            var id: Int!
            var lastName: String!
            var firstName: String!
            var teacher: Teacher!                        // so we can point to the teacher in our model
            var teacherReference: CKRecord.Reference!    // so we can point to records in CloudKit
            var gpa: Double!
            // other stuff omitted