title: How to add nested object to exising object in core data
body: <p>I have one to many objects <code>Driver &lt;--&gt;&gt; Car</code>.<br/>
  Classes:</p>
  
  <pre><code>class Driver: NSManagedObject {
     @NSManaged var fullName: String
      @NSManaged var cars: NSSet
  }
  class Car: NSManagedObject {
     @NSManaged var model: String
     @NSManaged var year: String
     @NSManaged var driver: Driver
  }
  </code></pre>
  
  <p>I inserted one Driver and a few car objects.<br/>
  But I don't know what is the proper way to update car list to add or remove some car object.<br/>
  Wired but I can't find any example on net how to do this.<br/>
  So how to just add new car to existing driver or remove car from it?<br/>
  <br/><strong>UPDATE</strong>
  I tried something like this but it saves new car in database but those new cars are not related to driver.<br/>
  When I fetch driver in <code>cars:NSSet</code> I am still getting one car.</p>
  
  <pre><code>let context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext;
  
          var newCar:Car = NSEntityDescription.insertNewObjectForEntityForName("Car", inManagedObjectContext: context!) as! Car
  
          newCar.year = "1977";
  
          var cars = driver?.cars.allObjects as! [Car]
  
          cars.append(newCar)
  
          var err: NSError?;
  
          context?.save(&amp;err);
  </code></pre>