arachide
arachide

Reputation: 8066

Is there a way to display the files in document directory with the sequence of modified date

I just wonder there a way to display the files in document directory with the sequence of modified date.

Welcome any comment

Thanks

interdev

Upvotes: 0

Views: 136

Answers (1)

Vladimir
Vladimir

Reputation: 170839

NSFileManager class provides access to file's attributes.

NSFileManager* manager = [NSFileManager defaultManager];
for (NSString *path in [manager contentsOfDirectoryAtPath: documentsDirectory error:nil]){
   NSDictionary* modDate = [manager attributesOfItemAtPath:
             [documentsDirectory stringByAppendingPathComponent:path] error:nil];
   NSDate* dateModified = (NSDate*)[modDate objectForKey: NSFileModificationDate];
   if (dateModified)
      NSLog(@"%@ .Date modified: %@", path, dateModified);
}

Upvotes: 3

Related Questions