sweethotdog
V2EX  ›  问与答

mac os 程序如何獲得要打開的文件路徑

  •  
  •   sweethotdog · Jul 20, 2013 · 3614 views
    This topic created in 4692 days ago, the information mentioned may be changed or developed.
    比如說
    我用 appleScript or xcode 編譯一個 app 後
    雙擊某個文本文件時我選擇用此 app 打開
    如何獲得要打開文件的路徑呢
    獲取後 我想執行
    vim path
    thks
    3 replies    1970-01-01 08:00:00 +08:00
    zhufenggood
        1
    zhufenggood  
       Jul 20, 2013 via iPhone   ❤️ 2
    打开terminal,把文件拖到terminal窗口上就变成路径了。
    dorentus
        2
    dorentus  
       Jul 20, 2013   ❤️ 1
    你是想要去参数?

    Cocoa GUI 程序的话,这样应该可以(http://stackoverflow.com/a/5147128/90172):

    NSArray *arguments = [[NSProcessInfo processInfo] arguments];

    其它的话,搜关键字『ARGV』吧,例如 https://www.google.com/search?q=ARGV+bash
    dorentus
        3
    dorentus  
       Jul 20, 2013
    打错字了。。第一行里的应该是『取参数』。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5323 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 08:17 · PVG 16:17 · LAX 01:17 · JFK 04:17
    ♥ Do have faith in what you're doing.