Question

Is it possible/Is there a file attribute to get the date, when a file was added to the mobile documents folder/icloud?

Was it helpful?

Solution

I've found the answer in another question here at stackoverflow:

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

The date-added attribute is in the Spotlight metadata:

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top