The UIDocument documentation says
To get autosaving capabilities for your documents, you must implement change tracking. Typically you do this by using an
NSUndoManager
object (assigned to undoManager
property) to register changes or by calling the updateChangeCount:
method every time the user makes a change; UIKit then automatically determines whether there are unsaved changes and returns the proper value from hasUnsavedChanges
.I have a UIDocument based app where I call updateChangeCount(.done) to indicate the document has changed. However, contentsForType is only called after a 15 second delay. This seems rather long to me.
Is there a way to increase the rate at which UIDocument responds to updateChangeCount? Or am I missing something?
No, that's about the typical interval before an autosave. In general, saving can be an expensive operation, so a more immediate autosave would be undesirable.
If you need to commit changes on a tighter schedule, you're going to have to do something manually. This could be an explicit save or autosave, or something like journalling of changes so they can be replayed in the event of a crash. But consider the effect on performance and (particularly) battery life.