Use NSOrderedSet from CoreData with UITableView

137 Views Asked by At

I'm trying to use an NSOrderSet in CoreData to populate my tableview. I have been able to read the count number of the NSOrderedSet, but can't seem to access the individual attributes of the Entity that makes up the NSOrderedSet.

I'm using this for the numberOrRows

 return (currentStatement.history?.count)!

Where currentStatement represents an Entity in CoreData and History is another Entity that has a toMany relationship with the Statement Entity.

I'm trying to access the History > date attribute like this inside the CellForRowAt method.

 print("\(currentStatement.history!.object(at: indexPath.row).date) saved date") // Looking for the date data that was saved
1

There are 1 best solutions below

0
On

Without knowing the actual issue you are running into, this should work:

let history = currentStatement.history?.object(at: indexPath.row) as! History
print("\(history.date) saved date")