Sectioned NSTableView using NSArrayController

后端 未结 3 2245
南方客
南方客 2021-02-15 10:18

I\'m trying to create a sectioned NSTableView using NSArrayController and cocoa bindings. I\'m searching for a similar approach like with NSFetch

3条回答
  •  旧巷少年郎
    2021-02-15 10:48

    You have to fill NSArrayController manually with a custom class instances that exactly holds the content of the NSTableView you want to accomplish, including the group rows. The controller must be filled in the correct order. So it should start with a group header object, then some data objects, a new header object, and so on. The custom class should contain the following properties:

    1. String value for the group header. Is nil when the row is no group header.
    2. Boolean value isGroupHeader. Needed for an easy tableView:isGroupRow: implementation.
    3. NSManagedObject value for your regular data. Is nil when the row is a group header.

    With this you have all the tools to implement all NSTableView delegates to get a properly grouped table view.

提交回复
热议问题