Core Data One to Many relationship

I have a object that is called Guest and I want to add a note to the guest. So note is the child of Guest.
Notes
One to Many Relationship
myCode
extension Notes {

@NSManaged var note: String?
@NSManaged var dateOfNote: NSDate?
@NSManaged var notes: Guest?

}

extension Guest {

@NSManaged var age: String?
@NSManaged var checkedOutDate: NSDate?
@NSManaged var checkingIncome: String?
@NSManaged var createdAt: NSDate?
@NSManaged var done: NSNumber?
@NSManaged var employmentIncome: String?
@NSManaged var eMS_ER: String?
@NSManaged var faithBase: String?
@NSManaged var firstName: String?
@NSManaged var foodStampsIncome: String?
@NSManaged var generalAssistanceIncome: String?
@NSManaged var hospiceOrHhAgency: String?
@NSManaged var insurance: String?
@NSManaged var insuranceCount: NSNumber?
@NSManaged var name: String?
@NSManaged var personContact1: String?
@NSManaged var personContact2: String?
@NSManaged var personPhoneContact1: String?
@NSManaged var personPhoneContact2: String?
@NSManaged var previouslyLivingAt: String?
@NSManaged var referredDate: NSDate?
@NSManaged var roomNumber: String?
@NSManaged var savingsIncome: String?
@NSManaged var socialSecurity: String?
@NSManaged var socialSecurityIncome: String?
@NSManaged var statusOfGuest: String?
@NSManaged var guest: NSSet?

}

To add a note to a guest, you need to create it as a managed object (i.e. insertIntoManagedObjectContext) before setting the properties.

Also, you probably want to switch the relationship names. That way “guest.notes” would refer to the NSSet of notes for that guest, and “note.guest” would refer to the guest that owns that particular note.

Hope that helps!