Get the Date, when the file was added to the mobile documents folder?
-
28-10-2019 - |
Pergunta
Is it possible/Is there a file attribute to get the date, when a file was added to the mobile documents folder/icloud?
Solução
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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow