问题描述
假设我有一堆存储在核心数据模型中的文章对象。每个文章保持读取进度属性,其表示用户已经读取了多少文章。一旦用户已完全阅读文章,文章将被标记为已读。在此之前,它将被标记为未读。
现在我有一个NSTableView绑定到一个NSArrayController包含所有使用CoreData存储的文章对象。
我知道这个方法
。我想让它显示未读组下的所有未读文章,- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row
pre>
在NSTableViewDelegate中。然而,这暗示我们必须在NSArrayController中有实际行说读取和未读,将被提升到组。因为NSArrayController包含从CoreData中提取的Article对象,我该怎么做呢?
注意:这是我的第一个问题, )
解决方案我建议使用NSOutlineview和NSTreeController来创建分组而不是NSTableView和NSArrayController。
Say I have a bunch of Article objects stored within the core data model. Each article maintains, a reading progress attribute which denotes how much of the article has been read by the user. Once the user has read the article fully, the article is marked as "Read". Before that, it would be marked "Unread".
Now I have an NSTableView bound to a NSArrayController containing all the Article objects stored using CoreData. I want it to display all unread articles under an "Unread" group, and all read articles under the "Read" group.
I know about the method
- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row
in the NSTableViewDelegate. However, this insinuates that we must have actual rows saying "Read" and "Unread" within the NSArrayController that will be promoted to group. Since the NSArrayController contains Article objects pulled from CoreData, how do I go about doing this?
NB: This is my first question here, and I'm new to Cocoa, please go easy on me :)
解决方案I suggest using NSOutlineview and NSTreeController to create grouping instead of NSTableView and NSArrayController.
这篇关于使用CoreData支持的NSArrayController在NSTableView中创建组行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!