2017-01-02 45 views
0

我想在CoreData中使用NSOrderSet來填充我的tableview。我已經能夠讀取NSOrderedSet的計數,但似乎無法訪問組成NSOrderedSet的實體的各個屬性。從CoreData與UITableView使用NSOrderedSet

我用這對numberOrRows

return (currentStatement.history?.count)! 

凡currentStatement代表CoreData實體和歷史是另一個實體具有與實體聲明一個一對多的關係。

我想要在CellForRowAt方法內訪問像這樣的歷史>日期屬性。

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

您有什麼問題? – shallowThought

+0

它將它更改爲:'cell.date.text =(currentStatement.history!.object(at:indexPath.row)as AnyObject).date'然後說:「不能將UILabel類型的值賦給鍵入字符串?「 – icekomo

回答

0

不知道你碰到的實際問題,這應該工作:

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