您如何在2016年获得文件的Finder“种类"? [英] How do you get the Finder “Kind” for a file, in 2016?

查看:110
本文介绍了您如何在2016年获得文件的Finder“种类"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此答案表示使用LSCopyKindStringForURL(),该方法在过去非常有效,但在OS中被标记为已弃用" X v10.11.

This answer says to use LSCopyKindStringForURL(), which has worked great in the past, but it's marked "deprecated" in OS X v10.11.

API文档中没有提及为什么不推荐使用它.我在OS X 10.11发行说明中根本没有提到启动服务API的更改.

There's no mention in the API documentation of why it was deprecated. I don't see any mention of Launch Services API changes in the OS X 10.11 release notes at all.

您现在应该如何获取文件的Finder类型?

How are you supposed to get the Finder Kind of a file now?

推荐答案

如果转到标题(/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSInfoDeprecated.h)中的LSCopyKindStringForURL()声明,则会在注释和不赞成使用的属性中找到以下内容:

If you go to the declaration of LSCopyKindStringForURL() in the header (/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSInfoDeprecated.h), you'll find in the comment and the deprecation attribute, the following:

改用URL资源属性kCFURLLocalizedTypeDescriptionKey或NSURLLocalizedTypeDescriptionKey.

Use the URL resource property kCFURLLocalizedTypeDescriptionKey or NSURLLocalizedTypeDescriptionKey instead.

这些是分别与CFURLCopyResourcePropertyForKey()-[NSURL getResourceValue:forKey:error:]一起使用的资源密钥.

These are resource keys for use with CFURLCopyResourcePropertyForKey() or -[NSURL getResourceValue:forKey:error:], respectively.

这篇关于您如何在2016年获得文件的Finder“种类"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆