Mac OS X 人机界面指南在有关 Windows 的部分中说道:
Note that if a user opens, moves, and closes a document window without making any other changes, you should save the new window position but you should not modify the file’s date stamp.
我们应该怎样做呢?如果我有一个基于文档的应用程序,并且我想在文件中保存文档窗口的位置和大小(而不触及其日期戳),我会覆盖 dataOfType:error
等。但是,只要我可以看出,所有这些都会自动修改文件的日期戳。
我认为只有一种方法可以做到这一点,这是一种黑客:使用 NSFileManager
临时保存文件的旧日期戳,保存窗口在文件中的位置,然后使用 setAttributes:ofItemAtPath:error
将其更改回来。
还有更好的办法吗?当然,如果这是一项常见任务......
最佳答案
将窗口的位置而不是文档保存在 NSUserDefaults 中怎么样?
关于macos - 苹果电脑 : Saving information to file without modifying date stamp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7864894/