macos 关联本地文件

2020-03-05 14:52:27 浏览数 (2)

在info.plist中加入:

代码语言:javascript复制
<key>CFBundleDocumentTypes</key>
   <array>
       <dict>
           <key>CFBundleTypeExtensions</key>
           <array>
               <string>abc</string>
           </array>
           <key>CFBundleTypeIconFile</key>
           <string>abc.png</string>
           <key>CFBundleTypeName</key>
           <string>abc file</string>
           <key>CFBundleTypeRole</key>
           <string>Editor</string>
           <key>LSTypeIsPackage</key>
           <true/>
           <key>NSPersistentStoreTypeKey</key>
           <string>XML</string>
       </dict>
   </array>

然后随便改个后缀名为xxxx.abc 默认打开方式就变成你的程序了。

0 人点赞