On Thursday, February 13, 2003, at 03:49 AM, Rich Morin wrote:
M'kay, then.What's the chance of your reworking your NSBrowser example into an NSOutlineView example?
If you enter a new path into the edit box, the "root" of the outline view changes to that path.
Double-clicking on a folder in the outline view changes the "root" to that folder.
NSOutlineView appears to depend on the data objects passed to it being retained. Normally, any object that has this requirement simply issues the retains itself, and corresponding releases when its finished with the objects it needed. But, NSOutlineView doesn't do that; you have to explicitly retain the objects you pass to it. This presents a problem, because you can't retain NSString objects in CB right now, as they're automagically converted to and from Perl scalars. This magic conversion will be enhanced in CB 0.3, to allow for access to the native NSString objects, but for now the workaround is to use NSAttributedString objects instead.
For the most part, I used Cocoa's NSDictionary, NSArray, and NSFileManager objects in this sample, instead of Perl hashes, arrays, and opendir/readdir functions. I figured the Perl stuff already has more documentation than you can shake a camel at, so doing it the "Cocoa Way" would be more useful as an example.
I did, however, use Perl's file test operators and stat() function in a couple of places. I suppose that can serve as an example, too - it shows you can mix-n-match techniques as needed to suit your purpose. The truth of it, though, is that I got lazy, and two-letter file tests are much less verbose than NSFileManager methods... ;-)
Once again, this will be part of 0.3 when it's released, but for now you can download it from my site:
<http://www.dot-app.org/OutlineSample.tgz>
sherm--
Welcome to Rivendell, Mr. Anderson.