Re: Filtering files in NSOpenPanel that NSAppleScript can run
Re: Filtering files in NSOpenPanel that NSAppleScript can run
- Subject: Re: Filtering files in NSOpenPanel that NSAppleScript can run
- From: "Adam R. Maxwell" <email@hidden>
- Date: Fri, 17 Nov 2006 07:52:51 -0800
On Nov 17, 2006, at 07:31, Sean McBride wrote:
On 2006-11-16 20:55, Adam R. Maxwell said:
There appear to be no UTIs for AppleScript. The only thing I can
think
of is to preflight each file by calling initWithContentsOfURL:error:
and
see if it fails (likely slow) or hardcoding the 5 extensions that
today's Script Editor can save (not future-proof).
It has UTIs com.apple.applescript.script and
com.apple.applescript.text, according to <http://www.devworld.apple.com/
documentation/Carbon/Conceptual/understanding_utis/utilist/
chapter_4_section_1.html
. I recently discovered these while trying to do the exact same
thing.
Ah, thanks for that! Odd that "com.apple.applescript" appears nowhere
in the 10.4 SDK, which I grepped before posting.
Of course, NSOpenPanel can't actually filter by UTIs. :( So what was
your final solution? Using Navigation Services? Using NSOpenPanel
with
a custom filter that checks each file's UTI?
I've never used Nav Services, and since my code was actually
superseded by other changes, I don't recall exactly what I did :).
Elsewhere I've used
NSDictionary *dict = [(id)UTTypeCopyDeclaration((CFStringRef)aType)
autorelease];
NSArray *types = [[dict objectForKey:(id)kUTTypeTagSpecificationKey]
objectForKey:(id)kUTTagClassFilenameExtension];
to extract path extensions from a UTI. You might be able to use
something similar? I've also created some NSWorkspace and NSString
category methods for getting the UTI of a URL and comparing them. As
an aside, do the UTType... functions show up for you in Xcode's
search? I can only find them in the header.
Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden