louisdh / textor

A plain text editor for iOS
MIT License
585 stars 113 forks source link

Document doesn't save if app goes to background without tapping "Done" #2

Open louisdh opened 6 years ago

a40yostudent commented 6 years ago

Hi! I could not reproduce this on the App Store version. To make the edits disappear, I have to go background then swipe up the app. Is this what you mean?

LeoNatan commented 6 years ago

Doesn't UIDocument save opportunistically in events, such as going to background? That's how it works for NSDocument. On app termination, it should have already saved.

a40yostudent commented 6 years ago

from Apple documentation:

In addition to the system terminating your app, the user can terminate your app explicitly using the multitasking UI. User-initiated termination has the same effect as terminating a suspended app. The app’s process is killed and no notification is sent to the app.

I'm looking at best practices, should be something related to applicationWillResignActive:

LeoNatan commented 6 years ago

That's not true. You hear in the app delegate applicationWillTerminate:.

Vercantez commented 6 years ago

I made a fix to this bug. Starting a PR

aamct2 commented 6 years ago

This is probably part of a larger discussion @louisdh in terms of what is correct behaviour with regards to auto-saving for the app.

1) Should the app ever auto-save or should that require explicit user action? 2) If the app provides auto-save, should we implement an UndoManager and register it with the UIDocument so that we get auto-saves happening as we go for free plus the ability to add user actions for undo/redo?

My preference would be: 1) We should generally be auto-saving. That's (relatively) common practice on iOS, especially with users jumping in an out of apps. 2) We should implement UndoManager and add user actions for it. It makes sense as most basic text editors have this.