NSTableView Sends Null Column to Delegate/DataSource

  • I am having a strange issue I haven't encountered before--for all of my data source and delegate methods the table view is sending nil for the table column, which obviously prevents me from fulfilling any of the requests. Has anyone seen this?

    Xcode 4, targeting 10.6.

    TIA,

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
  • A nil tableColumn means to treat the whole row as one wide column, rather than the individual columns. It is useful for section headers. The docs for the applicable methods should explain the nil tableColumn.

        john

    Sent from my iPhone

    On Jul 13, 2012, at 11:21 PM, Keary Suska <cocoa-dev...> wrote:

    > I am having a strange issue I haven't encountered before--for all of my data source and delegate methods the table view is sending nil for the table column, which obviously prevents me from fulfilling any of the requests. Has anyone seen this?
    >
    > Xcode 4, targeting 10.6.
    >
    > TIA,
    >
    > Keary Suska
    > Esoteritech, Inc.
    > "Demystifying technology for your home or business"
  • On Jul 13, 2012, at 10:44 PM, John Terranova wrote:

    > A nil tableColumn means to treat the whole row as one wide column, rather than the individual columns. It is useful for section headers. The docs for the applicable methods should explain the nil tableColumn.

    Thanks for the suggestion--although I knew this fact it did get me to re-read the docs more carefully and to experiment more, and I found the solution.

    I was experimenting with implementing group rows in a vanilla NSTableView, but when things were going awry I commented out tableView:isGroupRow:, thinking that this would eliminate group row handling, but no, it does not!

    For the archives, it is not safe to assume that tableView:isGroupRow: will determine which rows are actually group rows, at least if you implement tableView:dataCellForTableColumn:row:. It seems that regardless of whether you implement tableView:isGroupRow:, NSTableView will always send tableView:dataCellForTableColumn:row: a nil tablecolumn argument to determine whether the row is a group row (ostensibly). If you return an NSCell object, it will assume that the row is a group row and as a consequence will assume that *every* row is a group row unless the row returns nil.

    The solution was to both check for a nil tablecolumn value in tableView:dataCellForTableColumn:row *and* call my own implementation of tableView:isGroupRow: to make sure that the row is in fact a designated group row.

    > On Jul 13, 2012, at 11:21 PM, Keary Suska <cocoa-dev...> wrote:
    >
    >> I am having a strange issue I haven't encountered before--for all of my data source and delegate methods the table view is sending nil for the table column, which obviously prevents me from fulfilling any of the requests. Has anyone seen this?
    >>
    >> Xcode 4, targeting 10.6.

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
  • On Jul 14, 2012, at 10:08 , Keary Suska wrote:

    > For the archives, it is not safe to assume that tableView:isGroupRow: will determine which rows are actually group rows, at least if you implement tableView:dataCellForTableColumn:row:. It seems that regardless of whether you implement tableView:isGroupRow:, NSTableView will always send tableView:dataCellForTableColumn:row: a nil tablecolumn argument to determine whether the row is a group row (ostensibly). If you return an NSCell object, it will assume that the row is a group row and as a consequence will assume that *every* row is a group row unless the row returns nil.

    A group row is one drawn with with different style characteristics. (In a normal table, for example, it has a gradient shaded background.) This is controlled by 'tableView:isGroupRow:'.

    A group cell is one that draws the *entire row* as a single cell (and cells are not drawn per column). This is controlled by 'tableView:dataCellForTableColumn:nil row:'.

    The two things are orthogonal, although in many cases you'll want the the group row to use a group cell to span the width of the table. One case where you might use a group cell *not* in a group row is in an outline view, where expandable rows might not need to show column information like detail rows.
previous month july 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today