NSTableview and Core Data Entity's

Hi There.

I’m working with Core Data and displaying the data in a NSTableView.
From one Entity showing the data works fine and i’m abble to add data.
Bud what i want is to display records from multiple entity’s in one NSTableView.
At this time i can’t find any way to do this.

What i want is:
Entity: Customer.
With Attribute’s: firstName, surName …

Entity: Invoice.
With Attribute: invoiceDate, orderDate …

I’ve created an relation between the entity’s.

How can i show 1 row with the name of the customer and the invoiceData.

Hope you can help me.

Thanks.

Since you have a relationship between Customer and Invoice, you can simply call customer.invoiceDate:

do { customers =
try coreDataStack.context .executeFetchRequest(fetchRequest) as! [Customer]
tableView.reloadData()
} catch let error as NSError {
print("Could not fetch \(error), \(error.userInfo)")
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView
.dequeueReusableCellWithIdentifier(yourCellIdentifier)!
let customer = customers[indexPath.row]
cell.textLabel!.text = customer.name 
cell.detailTextLabel!.text = customer.Invoice?.invoiceDate
return cell }

Hi Marciokoko.

Thanks for your reply.

I’m going to look at your example.
I’m wanna do this with OSX and an NSTableView.

Thanks again.

Greetings.

After a lot of trying i got it to work.
I had to subclass the NSManagedObject.

Now it just works fine.