在Mac OS X上注册协议? [英] register a protocol on mac osx?

查看:232
本文介绍了在Mac OS X上注册协议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows中完成了操作,如何在Mac OS X上注册协议.我想单击firefox中的链接(a href ="somename://mylinkAndData")并启动二进制文件吗?

解决方案

看看苹果的 CFBundleURLTypes .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>
 ....

编辑:请参见在可可粉中使用URL方案

I have done it in windows, how do i register a protocol on mac osx. I want to click links in firefox (a href="somename://mylinkAndData") and launch a binary?

解决方案

Have a look at Apple's Launch Services Programming Guide. You have to add CFBundleURLTypes to your apps Info.plist and register your app with LSRegisterURL().

Excerpt from 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>
 ....

EDIT: See Handling URL schemes in Cocoa for a how-to article

这篇关于在Mac OS X上注册协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆