gpt4 book ai didi

objective-c - 应用程序未显示在支持文档类型的 "Open With"菜单中

转载 作者:搜寻专家 更新时间:2023-10-30 20:24:57 36 4
gpt4 key购买 nike

我已经定义了我的应用程序支持的 UTI,并且可以将它们拖到 Dock 图标上。我还在我的应用程序委托(delegate)中实现了 -application:openFiles: 和 -application:openFile: 。但是,当我获得有关我支持的 UTI 项目的信息时,它没有显示在列表中,并且在我浏览到“其他”时呈灰色显示。我从下面的 plist 中粘贴了一个示例 UTI。我做错了什么?我特别希望它与内置的 App Store 集成一起使用。

<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>cbz</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>CBZ</string>
<key>CFBundleTypeName</key>
<string>Comic Book Zip Archive</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.abbey-code.cbz-archive</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.zip-archive</string>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Comic Book Zip Archive</string>
<key>UTTypeIconFile</key>
<string>CBZ</string>
<key>UTTypeIdentifier</key>
<string>com.abbey-code.cbz-archive</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>cbz</string>
</array>
</dict>
</dict>
</array>

更新

我启动了一个虚拟机,除了我自己安装的应用程序外,没有第三方应用程序,一切都按预期工作。我已经像这样重建了我的 LaunchServices 数据库:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fra‌​mework/Support/lsregister -kill -r -domain local -domain system -domain user ; killall Dock

那没有什么区别。然后,我使用此命令转储了 LaunchServices 数据库,并在其下方显示了我的应用程序包的结果。这对我来说看起来很合理,但我不确定我在寻找什么。我是否可能遇到与系统上其他应用程序的某种类型的冲突?如果是这样,我将如何解决?

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fra‌​mework/Support/lsregister -dump >>lsregister.txt

转储:

bundle  id:            61808
path: /Applications/AppName.app
name: AppName
category: public.app-category.entertainment
identifier: com.abbey-code.AppName (0x800183e0)
canonical id: com.abbey-code.appName (0x8001a08d)
version: 6433.0
mod date: 5/6/2014 22:54:46
reg date: 5/7/2014 9:04:25
type code: 'APPL'
creator code: '????'
sys version: 10.9
exec sdk ver: 10.9
exec os ver: 10.9
flags: relative-icon-path
item flags: container package application extension-hidden native-app x86_64
hi res: is-capabile is-explicit user-can-change
app nap: is-capabile
icon: Contents/Resources/AppIcon.icns
executable: Contents/MacOS/AppName
inode: 37029967
exec inode: 37030002
container id: 32
library: Contents/Library/
library items: QuickLook/AppNameQL.qlgenerator/
--------------------------------------------------------
type id: 46888
bindableKey: 3266
generation: 7459
uti: com.abbey-code.cbz-archive
description: Comic Book Zip Archive
flags: exported active trusted
icon: Contents/Resources/CBZ.icns
conforms to: public.zip-archive, public.data
tags: .cbz
--------------------------------------------------------
type id: 46932
bindableKey: 3267
generation: 7459
uti: com.abbey-code.cbr-archive
description: Comic Book RAR Archive
flags: exported active trusted
icon: Contents/Resources/CBR.icns
conforms to: public.archive, public.data
tags: .cbr
--------------------------------------------------------
claim id: 37936
bindableKey: 3268
generation: 7459
name: Comic Book Zip Archive
rank: Owner
roles: Editor
flags: relative-icon-path
icon: Contents/Resources/CBZ.icns
bindings: com.abbey-code.cbz-archive
--------------------------------------------------------
claim id: 37972
bindableKey: 3269
generation: 7459
name: Comic Book RAR Archive
rank: Owner
roles: Editor
flags: relative-icon-path
icon: Contents/Resources/CBR.icns
bindings: com.abbey-code.cbr-archive
--------------------------------------------------------
claim id: 38008
bindableKey: 3270
generation: 1
name: PDF Document
rank: Default
roles: Viewer
flags:
icon:
bindings: .pdf
--------------------------------------------------------
claim id: 38044
bindableKey: 3271
generation: 1
name: RAR Archive
rank: Default
roles: Viewer
flags:
icon:
bindings: .rar
--------------------------------------------------------
claim id: 38080
bindableKey: 3272
generation: 1
name: ZIP Archive
rank: Default
roles: Editor
flags:
icon:
bindings: .zip
--------------------------------------------------------
claim id: 38116
bindableKey: 3273
generation: 7459
name:
rank: Default
roles: QLGenerator
flags:
icon:
delegate: QuickLook/AppNameQL.qlgenerator/
bindings: com.abbey-code.cbz-archive, com.abbey-code.cbr-archive

最佳答案

您可以将您的应用程序设置为在代码中针对特定文档类型默认启动的应用程序。我发现在某些情况下这是必要的,因为在 info.plist 中设置链接是不够的。这通常在您应用 Controller 的 +initialize 方法中:

    //First Check if our app is the default application to open .cbz files
NSString *cbzUTI = (NSString *)CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
(CFStringRef)@"cbz",
NULL));
NSString *currentCbzApp = (NSString *)CFBridgingRelease(LSCopyDefaultRoleHandlerForContentType((__bridge CFStringRef)cbzUTI, kLSRolesAll));

if ([currentCbzApp caseInsensitiveCompare:@"com.abbey-code.AppName"] != NSOrderedSame) {
//If not, then first register it in Launch Services
LSRegisterURL((__bridge CFURLRef)[[NSBundle mainBundle] executableURL], YES);
//Second set it as the default handler for the file type
LSSetDefaultRoleHandlerForContentType((__bridge CFStringRef)cbzUTI, kLSRolesAll,(__bridge CFStringRef) [[NSBundle mainBundle] bundleIdentifier]);
}

关于objective-c - 应用程序未显示在支持文档类型的 "Open With"菜单中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23508126/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com