Set date modified of files in Cocoa

How can I set the date modified attribute of a file in Cocoa? Thanks

Answers


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];

Need Your Help

Jackson overcoming underscores in favor of camel-case

java jackson

I retrieve a JSON string from internet; like most JSON I've seen it includes long keys that are separated by underscores. Essentially, my goal is to deserialize JSON into java-objects, but I don't ...

Is a Union Member's Destructor Called

c++ c++11 destructor unions standard-layout

C++11 allowed the use of standard layout types in a union: Member of Union has User-Defined Constructor