Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C: Get file creation / last modification date?

Tags:

objective-c

How can I get the file creation or last modification date of the file at a particular location, e.g. /Users/MYUSER/Downloads/text.txt?

like image 223
Alex Molskiy Avatar asked Sep 04 '10 11:09

Alex Molskiy


1 Answers

Example from Rosetta Code has deprecated parts. Here is the right code for getting file modification date

NSString *path = @"/Users/Raven/Downloads/1.png";
NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
NSDate *result = [fileAttribs objectForKey:NSFileCreationDate]; //or NSFileModificationDate
NSLog(@"%@",result);
like image 141
Alex Molskiy Avatar answered Oct 12 '22 02:10

Alex Molskiy