Mailing Lists: Apple Mailing Lists

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

Learning question about NSTableView and NSStrings



Hi,

I'm in the process of getting my head around Cocoa. My
latest test is playing around with the NSTableView. I have a
sample app that has a table view in a window and I have a
data source object created (don't ask my how I figured how
to set that up and wire it up!). I have an outlet in my data
source for the tableview (myTable).

In the interface for my data source, I define an array to
hold the data for the table (a one column table)
(NSMutableArray *myArray)
In the data source's awakeFromNib routine, I create the
array and stick some data into it: (first question-is this
the right place to do this?)

[[myArray alloc] init];
for (i=0; i<=10; i++)
{
[myArray addObject:@"Hello"]
}

(I would like each item to by "Line n" with n being the line
number, but I'm not sure how to set that)

I'm not even sure if that's the right way to set it. I know
it's a simple sample, but I want to start somewhere.

Now, in the tableView:setObjectValue:forTableColumn:row:
routine I do:

return [myTable objectAtIndex:row];
And in the numberOfRowsInTableView: routine I do:
return [myTable count];

It sort of works, except only 7 items show up in the table
view!

Anyone have any suggestions? One thing I'm working towards
is being able to click on one of the rows to "select" the
table, the be able to hit a key to go to the line that
starts with that letter. (Suggestions?)

Thanks,
John T.




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.