• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting last accessed date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting last accessed date


  • Subject: Re: getting last accessed date
  • From: "Rick C." <email@hidden>
  • Date: Fri, 08 Jul 2011 13:19:39 +0800

Thanks for the replies and yeah I get what you're saying.  The only thing with the spotlight metadata is it will depend on the spotlight index being enabled correct?  And yes it is the opened date I'm looking for.

One more note, seems in terminal "stat aFile" works so I suppose I could use nstask to do this as well?  I was just thinking there was a better way.

rc



On Jul 8, 2011, at 1:04 PM, Joar Wingfors <email@hidden> wrote:

> Hello Rick,
>
> The access date on a file is updated very frequently. I think that stat:ing the file is enough, and that happens all the time.
>
> If what you're looking for is the last *opened* date of the file, I think that your best bet is the kMDItemLastUsedDate spotlight metadata attribute.
>
> j o a r
>
>
> On 7 jul 2011, at 20:35, Rick C. wrote:
>
>> Hi again,
>>
>> I'm using this code to get the last accessed date of a file:
>>
>> struct stat output;
>>
>>   int ret = stat([aFile fileSystemRepresentation], &output);
>>   struct timespec accessTime = output.st_atimespec;
>>  NSDate *aDate = [NSDate dateWithTimeIntervalSince1970:accessTime.tv_sec];
>>
>>   NSLog(@"Access Time %d, %@",ret, aDate);
>>
>> But it's just giving me today's date.  There must be something obvious I'm doing wrong but I have not been able to figure it out.  Any pointers?  And I couldn't use NSURLContentAccessDate because I still need 10.5 support.  Thanks!
>>
>> rc_______________________________________________
>>
>> 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
>
_______________________________________________

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

  • Follow-Ups:
    • Re: getting last accessed date
      • From: Scott Ribe <email@hidden>
References: 
 >getting last accessed date (From: "Rick C." <email@hidden>)
 >Re: getting last accessed date (From: Joar Wingfors <email@hidden>)

  • Prev by Date: Re: getting last accessed date
  • Next by Date: Re: getting last accessed date
  • Previous by thread: Re: getting last accessed date
  • Next by thread: Re: getting last accessed date
  • Index(es):
    • Date
    • Thread