Re: read directory in table view
Re: read directory in table view
- Subject: Re: read directory in table view
- From: Tobias Hermann <email@hidden>
- Date: Sun, 23 Mar 2003 13:53:29 +0100
Hi!
An NSOpenDialog is not a TableView as far as I know... It is an
NSBrowser (or uses it).
There are two different ways of filling up such a browser. Both are
delegate methods:
First way (this method has to be implemented by the delegate object):
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column
inMatrix:(NSMatrix *)matrix
There you have to create the NSBrowserCells yourself and put them into
the passed Matrix which represents the column of the Browser to fill.
A bit tricky but in my opinion the cleaner version.
Second way (again these methods have to be present within the delegate):
- (int)browser:(NSBrowser *)sender numberOfRowsInColumn:(int)column
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell
atRow:(int)row column:(int)column
Read the documentation about Browsers in the Developer Help.
In both versions, you can set the text and the image of a browser cell.
To get the appropriate image for a filename, use
NSWorkSpace's iconForFile: method (i remember something like
[[NSWorkSpace sharedWorkspace] iconForFile: absolutePath];
To get the contents of a directory, use NSFileManager's method
directoryContentsAtPath:
Again, the documentation is your friend :-)
You can use NSBrowserCell's method setLeaf: to tell a cell if it is
"expandable" or not (if ist is a directory or not).
There is an example app named SimpleBrowser in the
/Developer/Examples/Appkit folder, but in my opinion it is not that
simple as the name might say. It may confuse you more than getting this
thing to work by yourself with less coding effort than this example
does.
best regards
Tobi
ps: Using these simple methods may result in a not that fast browser.
You could think about caching the contents of the already displayed
folders or such, but that is tricky!
As a starting point, this should be good enough.
On Sunday, March 23, 2003, at 12:59 PM, John Q. wrote:
Hi,
can somebody help me,
I would like to read a directory in an table view like in an
openDialog!!
Thanks for helping,
John
_______________________________________________
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.
_______________________________________________
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.