如何阅读文件注释字段 [英] How to read file comment field
问题描述
在OS X Finder中,具有注释"文件属性.可以在查找器中通过添加注释"列进行检查,或者在右键单击文件或文件夹并选择获取信息"后进行编辑/检查.
如何用swift或Objective-C读取此值?
我已经检查了NSURL,但似乎都不是正确的
In OS X Finder there is 'Comment' file property. It can be checked in finder by adding 'Comment' column or edited/checked after right clicking on file or folder and selecting 'Get info'.
How to read this value in swift or objective-c?
I checked already NSURL and none of them seems to be the right ones
推荐答案
请勿使用低级扩展属性API来读取Spotlight元数据.有一个合适的Spotlight API. (这称为文件元数据API.)这不仅使人痛苦不堪,而且不能保证Apple会继续使用相同的扩展属性来存储此信息.
Do not use the low-level extended attributes API to read Spotlight metadata. There's a proper Spotlight API for that. (It's called the File Metadata API.) Not only is it a pain in the neck, there's no guarantee that Apple will keep using the same extended attribute to store this information.
使用MDItemCreateWithURL()
为文件创建MDItem
.将MDItemCopyAttribute()
与kMDItemFinderComment
结合使用,以获取该项目的Finder注释.
Use MDItemCreateWithURL()
to create an MDItem
for the file. Use MDItemCopyAttribute()
with kMDItemFinderComment
to obtain the Finder comment for the item.
这篇关于如何阅读文件注释字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!