V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
sweethotdog
V2EX  ›  问与答

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

  •  
  •   sweethotdog · Jul 20, 2013 · 3566 views
    This topic created in 4671 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   ·   2501 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 15:12 · PVG 23:12 · LAX 08:12 · JFK 11:12
    ♥ Do have faith in what you're doing.