help w/ multiple columns in NSTableView

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default help w/ multiple columns in NSTableView

    Hey All,

    I'm trying to load a file with columns of data separated by white
    space and display it in an NSTableView. The file loads fine, but each
    line of data is being shown in each and every column for that row.
    Here's an example of four rows of data from the file.

    0 -0.749318 0.0892089 -1
    1 -0.171308 0.167947 1
    2 -0.651408 0.923422 -1
    3 0.380259 -0.414841 1

    My problem is that the first row of data is put in every column on the
    first row, the second row in every column of the second row, and so
    on. I'm not sure how to split the data up and place each item in a
    column.

    Below is my code.

    Any help much appreciated.

    --- mycontroller.mm ---

    - (void)filePanelDidEnd:(NSWindow*)sheet returnCode:(int)returnCode
    context:(void*)contextInfo
    {
    ...
    while ([scanner scanUpToString:@"\n" intoString:&currentLine])
    {
    ...
    listItems = [currentLine componentsSeparatedByString:@" "];
    }

    [lines addObject:listItems];
    }

    - (id)tableView:(NSTableView *)tableView
    objectValueForTableColumn:(NSTableColumn *) tableColumn row:(int)row
    {
    return [lines objectAtIndex:row];
    }
    Willian Irving Zumwalt Guest

  2. Similar Questions and Discussions

    1. displaying multiple columns in <cfselect>
      ok, I have a database that house a table called model. The model contains a manufacturer foreign key and 3 other fileds for that table. I want...
    2. STD of multiple columns
      Dear Mysql-ians, I want to calculate the standard deviation of data that are in multiple columns. I know how to calculate the STD of 1 column...
    3. Datagrid in multiple columns
      It is possible to arrange the datagrid it self into multiple columns? For example I have a grid with two items - id and name. I have over 600...
    4. Total of multiple columns in datagrid
      I am using VB 6 and have a bound datagrid pulling data from a Pervasive Database by ODBC connection. Column 3 shows opening balance and columns 4-15...
    5. [Cocoa] Bug with NSTableView?
      > I'll check these accessor methods, as this may be the problem. It was the setCol* methods that were causing the problem. I stupidly put:...
  3. #2

    Default Re: help w/ multiple columns in NSTableView

    Willian Irving Zumwalt <wizumwalt@yahoo.com> wrote:
    > I'm trying to load a file with columns of data separated by white
    > space and display it in an NSTableView. The file loads fine, but each
    > line of data is being shown in each and every column for that row.
    >
    > - (id)tableView:(NSTableView *)tableView
    > objectValueForTableColumn:(NSTableColumn *) tableColumn row:(int)row
    > {
    > return [lines objectAtIndex:row];
    > }
    You've no cause for complaint; Cocoa is doing exactly what your code is
    telling it to do. If you want Cocoa to do something else, you will have
    to write different code.

    For example, if you want various things to appear in various columns,
    you will need to use the tableColumn parameter you're being handed. The
    value you return will depend upon this, as well as upon the row
    parameter. Eh? m.

    --
    matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
    Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
    matt neuburg Guest

  4. #3

    Default Re: help w/ multiple columns in NSTableView

    [email]wizumwalt@yahoo.com[/email] (Willian Irving Zumwalt) wrote in message news:<dd8fee65.0309201458.68d040e4@posting.google. com>...
    > - (id)tableView:(NSTableView *)tableView
    > objectValueForTableColumn:(NSTableColumn *) tableColumn row:(int)row
    > {
    > return [lines objectAtIndex:row];
    > }
    objectValueForTableColumn is supposed to return different,
    column-specific information based on which column it is.
    So, you have to look at tableColumn, figure out which one
    it is, and then break up your line and return the correct
    chunk accordingly.
    Eric Pepke Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139