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»아이디 일정한 유형에«데이터 optr00000000207F220080600000»을 할 수 없습니다. (오류 -1700)

기록 된 출력이 어떻게 나타나는지에 대한 코드에 주석을 포함 시켰습니다. 나는 Xcode의 path to me 문제에 관한 유사한 질문이 이전에 요청되었고, set myPath to current application's NSBundle's mainBundle()'s bundlePath()은 현재 경로를 제공한다는 것을 이해합니다. 그러나 제 질문은 disk of 부분에 관한 것입니다.

Xcode에서 원하는 출력을 얻으려면 도움이됩니다.

그것은 강제 변환을 많이하지만, 엑스 코드에서 AppleScriptObjC 동등한 필요

답변

1

는 시동 볼륨이 /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 

입니다

관련 문제