在Mac沙盒应用中访问sidecar文件 [英] Access sidecar files in a Mac sandboxed app

查看:158
本文介绍了在Mac沙盒应用中访问sidecar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在基于文档的照片编辑器应用程序中访问sidecar XMP文件. 图像文件是文档,当用户打开并保存图像文档时,我需要访问sidecar XMP文件.

I need to access sidecar XMP files in a document-based photo editor application. The image files are the documents, and I need to access the sidecar XMP file when the user open and save an image document.

是否可以在基于沙盒的基于文档的应用程序中访问sidecar文件(例如XMP)?

Is it possible to access sidecar files (such as XMP) in a sandboxed document-based application?

我了解默认情况下这是不可能的,但是允许这样做的最小临时安全异常是什么?

I understand that it's not possible by default, but what is the minimal temporary security exception that is needed to allow that?

有没有不使用临时异常的解决方法?

Is there a workaround for this without using temporary exception?

请注意,无法保证将图像文件的文档范围书签保存到侧车(因为它们可能是由不同平台上的其他应用程序创建的),因此此解决方案将不起作用.

Note that it's impossible to guarantee the the image files document-scoped bookmarks to the side-cars (as they might created by other apps on different platforms), so this solution won't work.

推荐答案

虽然这个问题很旧,但我认为我会分享我的解决方案.您可以在NSIsRelatedItemType设置为true的情况下,在应用程序info.plist的CFBundleDocumentTypes部分中添加一个条目.然后,您的沙盒应用程序将能够打开用户允许使用的具有相同名称但具有您列出的扩展名的任何文件.这是一个xmp sidecar文件的示例:

While this question is old I thought I would share my solution. You can add an entry to your CFBundleDocumentTypes section in your apps info.plist with the NSIsRelatedItemType set to true. Then your sandboxed app will be able to open any file the user gives permission to with the same name but has the extensions that you list. Here is an example for an xmp sidecar file:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>xmp</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>XMP sidecar</string>
        <key>CFBundleTypeRole</key>
        <string>None</string>
        <key>NSIsRelatedItemType</key>
        <true/>
    </dict>
</array>

这篇关于在Mac沙盒应用中访问sidecar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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