Professional Web Applications Themes

dynamically create columns - Mac Programming

Hey all, I'm trying to dynamically create columns in my tableview as soon as I load a file and p it. Then I will display that data in my tables columns. I thought the below is all that would be needed but I see no columns. Any help much appreciated. --- - (void)filePanelDidEnd:(NSOpenPanel*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo { .... NSString * filename = [sheet filename]; NSLog("filename = %", filename); [projectWindow setTitle:filename]; NSTableHeaderCell *cellHeader = [[NSTableHeaderCellalloc]initTextCell"NSTableHeaderCell"]; NSCell *cellData = [[NSCell alloc]initTextCell:filename]; NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:"NSTableColumn"]; [column setHeaderCell:cellHeader]; [column setDataCell:cellData]; [tableView addTableColumn:column]; .......

  1. #1

    Default dynamically create columns

    Hey all,

    I'm trying to dynamically create columns in my tableview as soon as I
    load a file and p it. Then I will display that data in my tables
    columns. I thought the below is all that would be needed but I see no
    columns.

    Any help much appreciated.

    ---

    - (void)filePanelDidEnd:(NSOpenPanel*)sheet
    returnCode:(int)returnCode
    contextInfo:(void*)contextInfo
    {
    ....
    NSString * filename = [sheet filename];
    NSLog("filename = %", filename);

    [projectWindow setTitle:filename];

    NSTableHeaderCell *cellHeader =
    [[NSTableHeaderCellalloc]initTextCell"NSTableHeaderCell"];
    NSCell *cellData = [[NSCell alloc]initTextCell:filename];
    NSTableColumn *column = [[NSTableColumn alloc]
    initWithIdentifier:"NSTableColumn"];
    [column setHeaderCell:cellHeader];
    [column setDataCell:cellData];

    [tableView addTableColumn:column];
    ....
    Willian Guest

  2. #2

    Default Re: dynamically create columns

    In article <google.com>,
    com (Willian Irving Zumwalt) wrote:
     

    [snip obviously incorrect code]

    If you're going to give code, give the actual code that you are using
    and compiling. The code you posted will not compile.

    Your code looks correct in its basic outlines. Have you tried a
    [tableView setNeedsDisplay:YES] or a [tableView reloadData] after adding
    the column? Are you sure the column isn't just getting added off the end
    of your table view to the right where you can't see it?
    Michael Guest

  3. #3

    Default Re: dynamically create columns

    Besides the splitting up of lines that the google post did, what's
    wrong w/ the code so that it won't compile?

    I have tried your two suggestions, but neither did anything.

    Michael Ash <com> wrote in message news:<mail-FC07C3.10410915012004localhost>... 
    >
    > [snip obviously incorrect code]
    >
    > If you're going to give code, give the actual code that you are using
    > and compiling. The code you posted will not compile.
    >
    > Your code looks correct in its basic outlines. Have you tried a
    > [tableView setNeedsDisplay:YES] or a [tableView reloadData] after adding
    > the column? Are you sure the column isn't just getting added off the end
    > of your table view to the right where you can't see it?[/ref]
    Willian Guest

  4. #4

    Default Re: dynamically create columns

    In article <google.com>,
    com (Willian Irving Zumwalt) wrote:
     

    This line:

    NSTableHeaderCell *cellHeader =
    [[NSTableHeaderCellalloc]initTextCell"NSTableHeaderCell"];

    The missing space before 'alloc' could be somebody stripping tabs, but
    you're also missing a :. It looked like you retyped your code, which
    usually introduces weird typos and makes life harder for people trying
    to find the real problem.
     

    Nuts. Have you run this in the debugger to make sure that all of the
    variables are what you think they should be? For example, is tableView
    not nil? If it were nil, this code would execute and silently fail.
    Michael Guest

  5. #5

    Default Re: dynamically create columns

    Michael Ash <com> wrote in message news:<mail-19095E.10013116012004localhost>... 
    >
    > This line:
    >
    > NSTableHeaderCell *cellHeader =
    > [[NSTableHeaderCellalloc]initTextCell"NSTableHeaderCell"];
    >
    > The missing space before 'alloc' could be somebody stripping tabs, but
    > you're also missing a :. It looked like you retyped your code, which
    > usually introduces weird typos and makes life harder for people trying
    > to find the real problem.

    >
    > Nuts. Have you run this in the debugger to make sure that all of the
    > variables are what you think they should be? For example, is tableView
    > not nil? If it were nil, this code would execute and silently fail.[/ref]


    Yep, for some reason, it's nil. How is it that it's nil? Doesn't
    making an outlet point this to the actual object?
    Willian Guest

  6. #6

    Default Re: dynamically create columns

    In article <google.com>,
    com (Willian Irving Zumwalt) wrote:
     
    >
    > Yep, for some reason, it's nil. How is it that it's nil? Doesn't
    > making an outlet point this to the actual object?[/ref]

    Is your outlet actually hooked up? If not, it will remain nil.

    Do you have a method called 'setTableView:' which doesn't actually set
    your tableView variable? When you load a nib, the nib loader will first
    look for a method called 'setOutletName:' and call it, and if that
    doesn't exist then it searches your object directly for an instance
    variable called 'outletName'. People have run into gotchas because they
    created a 'setOutletName:' method that doesn't set the instance variable.

    Beyond that, hard to say. Check your nib, check your project, make sure
    that things have been loaded correctly, etc. etc.
    Michael Guest

Similar Threads

  1. dataGrid - dynamically re-order columns
    By skinnyfingers in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: April 11th, 09:23 PM
  2. dynamically building template columns
    By jonefer in forum ASP.NET Building Controls
    Replies: 4
    Last Post: May 26th, 06:08 PM
  3. Dynamically create datagrid columns
    By Terry Holland in forum ASP.NET Data Grid Control
    Replies: 18
    Last Post: October 8th, 07:05 AM
  4. Adding columns dynamically
    By Peter Kamitz in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: March 2nd, 06:11 PM
  5. How to add columns dynamically using Datgrid in C#
    By GP in forum ASP.NET Building Controls
    Replies: 0
    Last Post: August 27th, 10:03 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