Professional Web Applications Themes

help w/ multiple columns in NSTableView - Mac Programming

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. ...

  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. #2

    Default Re: help w/ multiple columns in NSTableView

    Willian Irving Zumwalt <wizumwalt> 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]matttidbits.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

  3. #3

    Default Re: help w/ multiple columns in NSTableView

    [email]wizumwalt[/email] (Willian Irving Zumwalt) wrote in message news:<dd8fee65.0309201458.68d040e4posting.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

Similar Threads

  1. Datagrid sorting on multiple columns
    By guygousse in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: November 19th, 04:17 AM
  2. STD of multiple columns
    By stefaan.lhermitte@agr.kuleuven.ac.be in forum MySQL
    Replies: 6
    Last Post: April 25th, 03:08 PM
  3. Datagrid in multiple columns
    By Arr in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: July 20th, 03:35 PM
  4. Total of multiple columns in datagrid
    By Ian Cook in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: April 19th, 11:15 PM
  5. [Cocoa] Bug with NSTableView?
    By Mark Bee in forum Mac Programming
    Replies: 1
    Last Post: July 7th, 07:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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