为什么NSFilePromiseProvider不接受“ public.email-message”作为有效的UTI?

时间:2019-11-24 22:57:06

标签: uti

我正在尝试向我的电子邮件客户端添加文件承诺支持,其中一部分是创建NSFilePromiseProvider的实例:

// This maps 'message/rfc822' to 'public.email-message'
NSString *Uti = LMimeToUti(MimeType); // App used mime-types internally.
if (Uti)
{
    auto delegate = [[LFilePromiseProviderDelegate alloc] init:FileName stream:Stream];
    auto prov = [[NSFilePromiseProvider alloc] initWithFileType:Uti delegate:delegate];
    NSArray *array = [NSArray arrayWithObject:prov];
    [pboard writeObjects:array];
}

但是NSFilePromiseProvider立即抛出断言:

2019-11-25 09:47:00.564551+1100 Scribe[3683:44013] [General] fileType 'public.email-message' is not a valid UTI
2019-11-25 09:47:00.574493+1100 Scribe[3683:44013] [General] (
    0   CoreFoundation                      0x00007fffae0b1b3b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffc333b1da objc_exception_throw + 48
    2   AppKit                              0x00007fffac427d17 -[NSFilePromiseProvider init] + 0
    3   LgiCocoa                            0x0000000100c776f3 _ZN15GDragDropSource4DragEP5GView7OsEventiP8GSurface + 2547
    4   Scribe                              0x000000010033e1ad _ZN5Thing11OnBeginDragER6GMouse + 349

如果我转到文件系统中的.eml文件并查看它的UTI:

mac-desktop:Desktop matthew$ mdls ./Your\ Cost\ of\ Living\ Summary.eml 
_kMDItemOwnerUserID            = 501
kMDItemContentCreationDate     = 2019-11-24 22:37:51 +0000
kMDItemContentModificationDate = 2019-11-24 22:37:51 +0000
kMDItemContentType             = "com.apple.mail.email"
kMDItemContentTypeTree         = (
    "com.apple.mail.email",
    "public.item",
    "public.data",
    "public.email-message",
    "public.message"
)

public.email消息似乎在那里有效。

也许它没有在我的应用程序中注册?因此,我查看了xcode项目的“信息”标签,并确保将UTI注册为已导入。所以我应该很好吧?

我在这里想念什么?

编辑:这是UTI的plist定义:

<key>UTImportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
            <string>public.message</string>
        </array>
        <key>UTTypeDescription</key>
        <string>Email Message</string>
        <key>UTTypeIdentifier</key>
        <string>public.email-message</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>eml</string>
            </array>
            <key>public.mime-type</key>
            <array>
                <string>message/rfc822</string>
            </array>
        </dict>
    </dict>
</array>

0 个答案:

没有答案