NSTableView, Cols and such...
NSTableView, Cols and such...
- Subject: NSTableView, Cols and such...
- From: Jason Leidigh <email@hidden>
- Date: Thu, 27 May 2004 04:57:46 -0300
Im am a serious Newbie so please forgive.....
I have a simple app with a button whose action is connected to a class.
The same class has an outlet back to the main window. All I am trying
to do is create an NSTableView in the main window upon pressing the
button. My code looks like this:
//NSCell *tblCellIconHeader = [[NSCell alloc] init];
//[tblCellIconHeader setBezeled:TRUE];
//[tblCellIconHeader setStringValue:@"Icon"];
NSTableColumn *tblCol1 = [[NSTableColumn alloc]
initWithIdentifier:@"icon"];
NSTableColumn *tblCol2 = [[NSTableColumn alloc]
initWithIdentifier:@"colname"];
[tblCol1 setWidth:50];
[tblCol2 setWidth:50];
[[tblCol1 headerCell] setStringValue:@"Icon"];
[[tblCol2 headerCell] setStringValue:@"Column Name"];
[[tblCol1 headerCell] setBezeled:TRUE];
[[tblCol2 headerCell] setBezeled:TRUE];
NSRect cFrame = NSMakeRect(100,100,100,100);//[[window contentView]
frame];
/* create the NSTextView and add it to the window */
NSTableView *theTableView = [[NSTableView alloc] initWithFrame:cFrame];
//[theTableView addTableColumn:tblCol1];
//[theTableView addTableColumn:tblCol2];
[theTableView setDrawsGrid:TRUE];
[theTableView setHighlightedTableColumn:tblCol1];
//[theTableView setBackgroundColor:blueColor];
[[mainWindow contentView] addSubview:theTableView];
[mainWindow makeKeyAndOrderFront:theTableView];
[mainWindow makeFirstResponder:theTableView];
If I leave the addTableColumn calls commented I get a nice blank white
frame indicating that the table has been placed in the contentView, but
if I uncomment the two addTableColumn instructions I get nothing. No
errors, no table with two cols and no white rectangle. Any ideas? Also
if I use the setBackgroundColor the entire app hangs and errors out.
Is "blueColor" not valid? I got it straight from the docs. If anyone
can point me to some tutorials more focused on using Cocoa
programatically and with less dependence on IB that would be a great
help too!! Thanks
- Jason
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.