Access sidecar files in a Mac sandboxed app

前端 未结 1 1102
栀梦
栀梦 2020-12-10 22:14

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 o

相关标签:
1条回答
  • 2020-12-10 23:12

    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>
    
    0 讨论(0)
提交回复
热议问题