Strangely this works in Script Debugger 5.0.12 but not in Script Debugger 8.0.6 or Apple’s Script Editor.
macOS 10.14.6 Mojave
MacBookAir5,2
-Chris
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set posixPathList to {"/Users/chris/Desktop/FastScripts ⇢ Search & Replace Evaluation.scpt", "/Users/chris/Desktop/REBUTTAL.scpt", "/Users/chris/Desktop/test.txt"}
set theNSArray to current application's NSArray's arrayWithArray:posixPathList
set theURLs to theNSArray's fileURL --<<-- Script Debugger 8.0.6 (8A66) on OSX 10.14.6 fails here.
return theURLs as list
--> Error: Can’t get fileURL of «class ocid» id «data optr00000000609E070000600000».
NSString nor NSURL have a fileURL method. You may see a such-named function if you look at the Swift API, but the ObjC API – which we’re using with ASObjC bridge – does not have it.
If you want to construct an NSURL object from a String, you need to use NSURL’s fileURLWithPath: instead.
I think Shane is implying that NSString does have an undocumented (private?) fileURL function, but I’m not sure. I find his reply a bit too cryptic.
At one stage the NSString subclass used for paths, NSFilePath, had a fileURL property. So the property was undocumented by way of belonging to a private subclass. But the property came and went, as did the subclass itself.