Re: NSTableView
Re: NSTableView
- Subject: Re: NSTableView
- From: Andrew Merenbach <email@hidden>
- Date: Thu, 28 Feb 2008 16:52:19 -0800
Hi, Jeremy,
You appear to have a few corrections that need to be made with your
code. To resolve these will help you on your way. You should make
the following changes before you try to get things working:
1. Remove the extraneous retain from your categoriesArray
instantiation -- -alloc and -init produce a retained object.
2. Change:
NSString *string;
string = [NSString init];
string = @"Main Category";
to
NSString *string = @"Main Category";
or
NSString *string = [NSString stringWithString:@"Main Category"];
3. Also note that [NSString init] is improper; you need [[NSString
alloc] init] or [NSString string] -- but no matter what, it's a waste
if you immediately set string to @"Main Category".
4. Is your controller class with the code that you gave all set up as
the dataSource for the table view? You'll need to connect that in
Interface Builder.
If I can be of any more service, let me know.
Cheers,
Andrew
On Feb 28, 2008, at 4:41 PM, Jeremy wrote:
This is how I am attempting to do it...
In awakeFromNib:
categoriesArray = [[[NSMutableArray alloc] init] retain];
NSString *string;
string = [NSString init];
string = @"Main Category";
[categoriesArray addObject:string];
[categories selectRow:1 byExtendingSelection:NO];
[categories scrollRowToVisible:1];
And my informal protocols:
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [categoriesArray count];
}
- (id)tableView:(NSTableView *)aTableView objectValueForColumn:
(NSTableColumn *)aTableColumn row:(int)row
{
return [categoriesArray objectAtIndex:row];
}
The NSTableView is not being populated at all... No rows, and
nothing else....
Jeremy
"For a long time it puzzled me how something so expensive, so
leading edge, could be so useless, and then it occurred to me that a
computer is a stupid machine with the ability to do incredibly smart
things, while computer programmers are smart people with the ability
to do incredibly stupid things. They are, in short, a perfect
match." - Bill Bryson
On Feb 28, 2008, at 7:39 PM, Hamish Allan wrote:
On Fri, Feb 29, 2008 at 12:34 AM, Jeremy <email@hidden>
wrote:
I am trying to figure NSTableViews out. I have two table views
inside
of my window. The code I have is completely useless and not working.
Can anyone explain how to populate an NSTableView using arrays? If
you
could that would be greatly appreciated.
You should explain how what you are trying to do differs from what is
covered in the various basic tutorials for using NSTableViews;
otherwise we will not know how to address your question.
Hamish
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden