The documentation for NSUserScriptTask claims that instantiating that class directly will work on any valid file and return the appropriate kind of task:
The returned object will be of one of the specific sub-classes (NSUserUnixTask, NSUserAppleScriptTask, and NSUserAutomatorTask), or
nil
if the file does not appear to match any of the known types.If invoked from a subclass, the result will be that class or
nil
.
In reality, I found that (as of 10.8.2) NSUserScriptTask unconditionally returns nil
and a “what is this i dont even” error. It seems that you need to instantiate the correct task subclass yourself. Probably worth filing a bug.
To test whether a file is usable as a script task (e.g., in an Open panel validation method), all I can suggest is to try instantiating each of the three classes, returning YES
if any of them succeeds and NO
if all of them fail.