【发布时间】:2012-08-22 07:49:54
【问题描述】:
我正在文件系统中缓存一些用户信息。然后使用
阅读NSData *cachedMessagesData = [NSData dataWithContentsOfURL:fileDirectoryForUserInfoCache];
我需要知道每个缓存文件的访问时间,但是,当我使用 Property 键检查访问时间时:
NSArray *filesInUserInfoCacheDirectory = [self.fileManager contentsOfDirectoryAtURL:self.cacheDirectoryForUserInfo includingPropertiesForKeys:[NSArray arrayWithObjects:@"NSURLCreationDateKey", @"NSURLContentAccessDateKey", nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];
NSDate *accessDate = [[[filesInUserInfoCacheDirectory lastObject] resourceValuesForKeys:[NSArray arrayWithObject:@"NSURLContentAccessDateKey"] error:nil] objectForKey:@"NSURLContentAccessDateKey"];
我发现访问日期与文件创建日期相同。通过 [NSData dataWithContentOfURL:...] 读取文件不会更改文件的访问时间属性。
谁能告诉我为什么?有没有办法读取文件以更新访问时间?非常感谢提前。
【问题讨论】:
标签: nsurl