是否可以/当文件被添加到移动文档文件夹/ icloud时,是否有文件属性来获取日期?
答案 0 :(得分:0)
我在stackoverflow的另一个问题中找到了答案:
Where does the Finder obtain the "date added" of an item in a folder?
添加日期的属性位于Spotlight元数据中:
NSDate *dateAdded(NSURL *url)
{
NSDate *rslt = nil;
MDItemRef inspectedRef = nil;
inspectedRef = MDItemCreateWithURL(kCFAllocatorDefault, (CFURLRef)url);
if (inspectedRef){
CFTypeRef cfRslt = MDItemCopyAttribute(inspectedRef, (CFStringRef)@"kMDItemDateAdded");
if (cfRslt) {
rslt = (NSDate *)cfRslt;
}
}
return rslt;
}