【问题标题】:Content modification date of an file in CocoaCocoa 中文件的内容修改日期
【发布时间】:2013-07-03 15:28:20
【问题描述】:

如何知道文件上次在 Cocoa 中的修改时间?

我尝试使用 NSFile 的 NSFileModificationDate 属性,但是当您读取文件时修改日期会更新。我只是想知道上次更改的时间,例如在 Mac OS X Finder 中。

【问题讨论】:

    标签: ios objective-c cocoa-touch file nsfilemanager


    【解决方案1】:

    你可以试试下一个代码:

    NSDate *fileModificationDate = nil;  
    [fileUrl getResourceValue:&fileModificationDate forKey:NSURLContentModificationDateKey error:nil];
    NSLog(@"modification date %@", fileModificationDate)
    

    您可以在 NSURL.h - NSURLContentModificationDateKey 等中看到资源键。 希望它会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多