2017-01-02 3 views
0

大きなプロジェクトの一環として、私のスクリプトをホストするデバイスのマウントポイントのパスを取得したいと思います。
私はスクリプトエディタで次のコードを設計しましたが、ApplescriptObjC(Xcode)で実装すると、エラーが発生し始めたことに気付きました。ディスクへのApplescriptObjCパス(ホストドライブ)

# 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 

«クラスocid»タイプの定数に、id«データoptr00000000207F220080600000»を作ることはできません。 (エラー-1700)

ログ出力がどのように表示されるかについてのコードにコメントが含まれています。 私はXcodeのpath to me問題に関する同様の質問が以前に尋ねられており、set myPath to current application's NSBundle's mainBundle()'s bundlePath()は現在のパスを示していることを理解していますが、私の質問はdisk ofに関するものです。

Xcodeで希望の出力を得るための助けを歓迎します。

答えて

1

それは、型変換の多くを必要としますが、XcodeでAppleScriptObjC当量が起動ボリュームが/Volumes/<volumeName>

によって他のすべてのボリューム /で表される

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 

です

関連する問題