最初に書いたやり方だと、アプリからホーム画面に行ってアプリに戻るとリセットされませんでした。
今は以下のようにしています。今のところよく動いています。
AppDelegate.swift
...
func applicationWillEnterForeground(application: UIApplication) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
storyboard.instantiateViewControllerWithIdentifier("MainViewController")
}
...
"MainViewController"
にはInitial View Controllerを入れて下さい。これでフォアグラウンドに出るたびにアプリ全体が初期化されます。
最初に書いたやり方
Info.plistに以下の項目を追加する
Application does not run in background: YES
アプリがおかしくなったときにユーザーがリセットすることができる。アプリがまだ不安定なときに使える。