你可以使用
MDItem…
CoreServices框架中的函数:
import Foundation
import CoreServices
let path = someURL.path
if let mditem = MDItemCreate(nil, path as CFString),
let mdnames = MDItemCopyAttributeNames(mditem),
let mdattrs = MDItemCopyAttributes(mditem, mdnames) as? [String:Any] {
print(mdattrs)
print(“Creator: (mdattrs[kMDItemCreator as String] as? String ?? “Unknown”)”)
} else {
print(“Can’t get attributes for (path)”)
}
</code>
有关详细信息,请参阅
文件元数据
核心服务框架的一部分。