title: Swift CoreData saving a one-to-one relationship
body: <p>Below I have a handful of segmented controls that I'm trying to save using <code>CoreData</code>. It seems pretty straight forward, but only the most recent control index is being saved. The rest are being reset to 0 for some reason. I have unchecked the default setting for each attribute. </p>
  
  <p><code>Quote</code> is my main entity and has a one-to-one relationship with <code>Worksheet</code> called <code>worksheet</code>. </p>
  
  <pre><code>@IBAction func segmentPressed(_ sender: UISegmentedControl) {
     let worksheet = Worksheet(context: context)
  
     switch sender.tag {
     case 0:
        worksheet.irrigation = Int32(irrigationSegment.selectedSegmentIndex)
     case 1:
        worksheet.waste = Int32(wasteSegment.selectedSegmentIndex)
     case 2:
        worksheet.water = Int32(waterSegment.selectedSegmentIndex)
     default:
        break
     }
  
     if let quote = currentQuote as? Quote {
        quote.worksheet = worksheet
        appD.saveContext()
     }
   }
  </code></pre>
  
  <p>UPDATE: It occurred to me to get rid of the switch statement altogether...and now it saves properly. But I'd still like to know why the values were being reset. Maybe an Int attribute automatically gets set to zero when its context is saved but it has no value? It seems like that's what the default value setting would do. Except mine were all unchecked.</p>