在mac osx上注册协议?

8 macos protocols

我在windows中完成了它,我如何在mac osx上注册协议.我想点击firefox中的链接(一个href ="somename:// mylinkAndData")并启动一个二进制文件?

f3l*_*lix 14

看看Apple的Launch Services Programming Guide.您必须将CFBundleURLTypes添加到您的应用程序Info.plist并使用LSRegisterURL()注册您的应用程序.

摘自Firefox.app/Contents/Info.plist:

    <key>CFBundleURLTypes</key>
    <array>
            <dict>
                    <key>CFBundleURLIconFile</key>
                    <string>document.icns</string>
                    <key>CFBundleURLName</key>
                    <string>http URL</string>
                    <key>CFBundleURLSchemes</key>
                    <array>
                            <string>http</string>
                    </array>
            </dict>
 ....
Run Code Online (Sandbox Code Playgroud)

编辑:请参见处理URL方案在可可如何做的文章