作为一个大型项目的一部分,我想获得托管我脚本的设备的Mount Point的路径 我在脚本编辑器中设计了以下代码,但是,在ApplescriptObjC(Xcode)中实现它时,我注意到错误已经开始。
# Get Mount Point of script USB host
tell application "Finder"
try
set usbMountPoint to text 1 thru -2 of POSIX path of (disk of (path to me) as alias)
log usbMountPoint # Output: /Volumes/usb-drive-name
on error
set usbMountPoint to POSIX path of (disk of (path to me) as alias) # if file is on desktop, path: '/', can't have '[space]' hence no removing
log usbMountPoint # Output: /Volumes/usb-drive-name
end try
end tell
无法将«class ocid»id«data optr00000000207F220080600000»转换为类型常量。 (错误-1700)
我在代码中包含了关于记录输出应该如何看的注释。
我理解之前已经询问过有关Xcode中path to me
问题的类似问题,并且set myPath to current application's NSBundle's mainBundle()'s bundlePath()
给出了当前路径,但是,我的问题与disk of
部分有关。
非常感谢在Xcode中获得所需输出的任何帮助。
答案 0 :(得分:1)
它需要大量的强制,但Xcode中的AppleScriptObjC等效于
set myPath to current application's NSBundle's mainBundle()'s bundlePath() as text
tell application "Finder" to set mountPoint to POSIX path of (disk of item (myPath as POSIX file as text) as alias)
log mountPoint
启动卷由/
/Volumes/<volumeName>
所有其他卷