question about last used date
question about last used date
- Subject: question about last used date
- From: "Rick C." <email@hidden>
- Date: Mon, 14 Mar 2016 17:24:45 +0800
Hi everyone,
I’m having some troubles getting the last used date of a file, can anyone see issues here with my code?
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:anObject error:NULL];
if (fileAttributes != nil)
{
MDItemRef item = MDItemCreate(NULL, (CFStringRef)anObject);
NSDate *aDate = (NSDate*)CFBridgingRelease(MDItemCopyAttribute(item, kMDItemLastUsedDate));
if (!aDate)
{
NSDate *fileCreateDate = [fileAttributes objectForKey:NSFileModificationDate];
}
}
My problem is I’m only getting a kMDItemLastUsedDate on about 10% of files I check, and even though I always get a value for NSFileModificationDate it still doesn’t seem to always be the true last used date. For example looking at how Path Finder does it they have an Attribute tag that seems to more correctly give the last date file was used. Any input here would be appreciated thanks in advance...
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden