Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not able to add columns to a NSTable



On Jan 27, 2004, at 12:32 AM, Amit Sadana wrote:
NSTableView *myTableView = [[NSTableView alloc] init];

[myTableView initWithFrame:myRect];

This is nonsensical. You're allocating an NSTableView, initializing it with a bogus -init, and then sending it -initWithFrame:. Also, since the table view is going to be added to your view, you should autorelease it immediately. In other words:

NSTableView *myTableView = [[[NSTableView alloc] initWithFrame:myRect] autorelease];

NSTableColumn *tc1 = [[NSTableColumn alloc]
initWithIdentifier:name1];

NSTableColumn *tc2 = [[NSTableColumn alloc]
initWithIdentifier:name2];

Since you're going to add these to the table, you should autorelease them as soon as you create them.

NSTableColumn *tc1 = [[[NSTableColumn alloc] initWithIdentifier:name1] autorelease];
NSTableColumn *tc2 = [[[NSTableColumn alloc] initWithIdentifier:name2] autorelease];

I'm not sure why it's not showing up when you add it to your view. Are you sure its frame is in the correct place in its superview's coordinate system?

Is there a way you can create more of your interface using Interface Builder, and just load it and wire it up at run-time instead of creating it on the fly? There are times when you need to do so, but most of the time you don't when working with Cocoa.

-- Chris

--
Chris Hanson <email@hidden>
bDistributed.com, Inc.
Outsourcing Vendor Evaluation
Custom Mac OS X Development
Cocoa Developer Training
_______________________________________________
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.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.