Core Data One-To-Many Swift
<p>The question i have is in regards to a <code>Core Data</code> <code>one-to-many relationship</code> as of right now i have my app being able to let the user input employee information and saving to <code>core data</code>, then updating the <code>employee</code> table view. The problem i face is the relationship between the <code>employee</code> and delivery. Im currently trying to display a specific employees deliveries when clicking on an <code>employee</code> in the <code>employee</code> table view. After selecting an employee from the employee tableView i want it to segue to another tableview and display the employees deliveries in another <code>UITableview</code>.</p>

<p>What I'm trying to Accomplish:</p>

<pre><code>1) Display Specific Employee's Deliveries

2) Add deliveries to the NSSet
</code></pre>

<p>Here are my two <code>managedObjects</code></p>

<pre><code>extension Delievery {

    @NSManaged var address: String?
    @NSManaged var phoneNumber: String?
    @NSManaged var subTotal: NSNumber?
    @NSManaged var total: NSNumber?
    @NSManaged var employee: Employee?

}

extension Employee {

    @NSManaged var first: String?
    @NSManaged var last: String?
    @NSManaged var phoneNumber: String?
    @NSManaged var wage: NSNumber?
    @NSManaged var id: NSNumber?
    @NSManaged var delievery: NSSet?

}
</code></pre>

<p>how i prepared for segue from <code>employeeTableViewController</code> to <code>deliveryTableViewContorller</code></p>

<pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue == "DelieverySegue"{
        let employeeDeliveries = segue.destinationViewController as! DelieveryTableViewController



        let indexPath = self.tableView.indexPathForSelectedRow



        let selectedEmployee = employees[indexPath!.row]

        employeeDeliveries.employee = selectedEmployee





    }
}
</code></pre>

<p>The variables of the deliveryTableViewController are</p>

<pre><code>var employee: NSManagedObject!


var deliveries : [NSManagedObject]!


var managedObjectContext : NSManagedObjectContext!
</code></pre>

<p>In this photo it shows the rest of my <code>deliveryTableViewController</code> the problem i have is how do i return the amount of deliveries for a specific employee in the <code>numberOfRowsInSection</code> function and how do i fetch the deliveries of the employee.
<a href="https://i.stack.imgur.com/2r05o.png" rel="nofollow noreferrer">deliveryTableViewController set up</a></p>

<p>In this last photo my question is how to i add this delivery entry to the employee selected? this is how I'm currently saving my delivery entries
<a href="https://i.stack.imgur.com/vOqQv.png" rel="nofollow noreferrer">how i save my delivery entries</a></p>

<p>If you made it this far i appreciate you looking through my problem. If anyone can help me the slightest with this issue i'd appreciate it if you feel i've left some information out that is needed please let me know. </p>

<p>UPDATE: </p>

<p>Here is the picture of the DelieveryTableViewController (yes i know i spelt delivery wrong)</p>

<p><a href="https://i.stack.imgur.com/2r05o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2r05o.png" alt="Picture of DelieveryTableViewController with viewDidLoad()"></a></p>

<p>also need to set the NSPredicate </p>

<p><a href="https://i.stack.imgur.com/vOqQv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vOqQv.png" alt="Picture of DeliveryTableViewController fetchRequest function"></a></p>

<p>this is home I'm preparing for segue in EmployeeTableViewController</p>

<p><a href="https://i.stack.imgur.com/PNgcw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PNgcw.png" alt="enter image description here"></a></p>

<p>these are my variables for EmployeeTableViewController</p>

<p><a href="https://i.stack.imgur.com/Yd14R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yd14R.png" alt="enter image description here"></a></p>