我正在使用coredata框架。現在我有這個問題:
我有關係[1:n]
Order
和OrderDetail
對象。 在第一個tableview中,我使用NSFetchedResultsController
來獲取Order
的列表。 我的問題是如何計數Ordertail
每個Order
。CoreData有什麼不同
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
我得到了Order
對象。稱它爲parent_Object。
什麼是計數OrderDetail
的好辦法:
- 使用
NSFetchRequest
與謂詞"Order == %@'
,parent_Object。然後我計算結果獲取數組。 - 使用性質:
parent_Object.OrderDetails.count
有什麼區別和方式將節省的時間執行。
請幫我一把。
請注意:'count'是不是一個性質,它是一種方法!點語法確實有效,但當它不是一個簡單的getter時,請堅持使用方括號括起來的方法調用! – Joost 2011-12-21 10:06:07