object-c add my program to open in
时间: 2023-02-17 12:46:45 浏览: 53
如果你想要让你的程序可以在 macOS 中打开,可以在你的应用的 Info.plist 文件中添加 CFBundleDocumentTypes 和 LSHandlerRank 字段,然后设置这两个字段的值,就可以让你的应用程序可以在 macOS 中打开了。
CFBundleDocumentTypes 字段用于指定应用程序能够打开的文件类型,格式如下:
```
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>My Document Type</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>com.example.my-document-type</string>
</array>
</dict>
</array>
```
LSHandlerRank 字段用于指定应用程序的打开优先级,格式如下:
```
<key>LSHandlerRank</key>
<string>Alternate</string>
```
其中,Alternate 表示次要应用程序,Owner 表示主要应用程序,None 表示不能作为打开文件的应用程序。
详细的文档可以参考 Apple 的官方文档:
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8
希望这能帮到你!