Cocoa NSDocument: getting autosave to work
Asked Answered
L

2

5

Documentation simply states that setting setAutosavingDelay to anything > 0 on the shared doc controller should do it, but after calling

[[NSDocumentController sharedDocumentController] setAutosavingDelay:2.0];

in my controller, autosave doesn't seem to work: I neither see anything in ~/Library/Autosave Information/, nor is

[[[NSDocumentController sharedDocumentController] currentDocument] autosavedContentsFileURL]

initialized.

Note that in my app, normal loading and saving work fine (keyedarchivers, nscoding-based class for my docs, etc).

Lapidary answered 2/1, 2009 at 22:13 Comment(2)
Just as a sanity check, you did make a change to the document so there was something to auto save? (and see what -hasUnautosavedChanges reports)Francesco
and your NSDocument return yes for autosavesInPlace?Baccarat
L
8

Have you overridden -updateChangeCount: at all? I'm pretty certain that Apple's implementation is the code that starts up the autosave timer. Also, what if you experiment with a longer timer?

Linguistic answered 3/1, 2009 at 17:37 Comment(1)
Thanks. I haven't. I'll give both a try and get back.Lapidary
O
2

Some people find that the directory ~/Library/Autosave Information is owned by root, and so files can not be written therein. See for example http://discussions.apple.com/thread.jspa?threadID=2252306

I don't know how the bug arises but I was bitten by it -- the directory was created 2010-06-17 12:19 and I assume that the permissions were wrong from that moment.

Officinal answered 1/8, 2010 at 4:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.