Set date modified of files in Cocoa
How can I set the da开发者_运维知识库te modified attribute of a file in Cocoa? Thanks
What about NSFileManager
setAttributes:ofItemAtPath:error:
method?
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html
Attributes are a dictionary. You can set a modification date value with the NSFileModificationDate
key.
Basically:
NSDictionary* attr = [NSDictionary dictionaryWithObjectsAndKeys: yourDate, NSFileModificationDate, NULL];
[[NSFileManager defaultManager] setAttributes: attr ofItemAtPath: yourPath error: NULL];
精彩评论