获取 Info.plist 的所有 CFBundleTypeExtensions

发布于 2024-09-16 09:50:36 字数 452 浏览 2 评论 0原文

我想获取我的应用程序可以打开的所有文件的扩展名。我想从我的 Info.plist 中获取它们。现在我有这个,但是有更好的选择吗?

NSMutableArray *types = [NSMutableArray new];
NSArray *documentTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleDocumentTypes"];
for (NSDictionary *dict in documentTypes) {
    for (NSString *extension in [dict objectForKey: @"CFBundleTypeExtensions"])
        [types addObject: extension];
}
return [types autorelease];

提前致谢。

I would like to get all the extensions of files my app can open. And I'd like to get them from my Info.plist. Right now I have this, but is there a better alternative?

NSMutableArray *types = [NSMutableArray new];
NSArray *documentTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleDocumentTypes"];
for (NSDictionary *dict in documentTypes) {
    for (NSString *extension in [dict objectForKey: @"CFBundleTypeExtensions"])
        [types addObject: extension];
}
return [types autorelease];

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓬勃野心 2024-09-23 09:50:36

在项目的 info.plist 中,只需输入星号(“*”)作为 CFBundleTypeExtension 的一项,如下图所示。

输入图片此处描述

In the info.plist of your project just enter an asterisks ('*') as an item of CFBundleTypeExtension as shown in the picture below.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文