2012-01-14 49 views
0

是否有可能/是否有文件屬性來獲取日期,當文件被添加到移動文檔文件夾/ icloud?獲取日期,當文件被添加到移動文檔文件夾?

+1

從iOS或...? – 2012-01-14 13:29:53

+0

這不是文件的'NSFileCreationDate'屬性看看[NSFileManager - attributesOfItemAtPath](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference .html) – 2012-01-14 13:36:39

+0

在Mac上... 不,NSFileCreationDate只會工作,如果我會創建新的文件,但不起作用,如果您複製/移動文件到文件夾。 – fabianpimminger 2012-01-18 10:03:11

回答

0

我發現在另一個問題的答案在這裏計算器:

Where does the Finder obtain the "date added" of an item in a folder?

添加的日期屬性是在聚光燈元數據:

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; 
} 
相關問題