Question

I'm writing a Cocoa application that displays the contents of an archive file in an NSOutlineView. I provide a custom icon for an NSBrowserCell in the outline column, and it works great, but I ran into a little snag — using [NSImage imageNamed:@"NSFolder"] returns the correct image (a generic folder icon) on 10.6, but on 10.5 it returns nil, so all the folder icons disappear. (I can't find any documentation on the NSFolder icon name to see when it was introduced — I got it working by trial and error.)

Is there a non-deprecated method for getting a generic folder icon that works on both 10.5 and 10.6?

Was it helpful?

Solution

[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)]

(I think)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top