开发者

Get all CFBundleTypeExtensions of an Info.plist

开发者 https://www.devze.com 2023-01-12 23:58 出处:网络
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?

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.


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

Get all CFBundleTypeExtensions of an Info.plist

0

精彩评论

暂无评论...
验证码 换一张
取 消