iosobjective-cxcodecrashcrash-reports

how do we know if ios app is crashed in last launch?


How do we know if ios app is crashed in last launch?

I would like to reset some settings when app is launched and finds that app was crashed in last session. Like not to prompt for rating.


Solution

  • One way would be to create an empty file, say, lock_file.tmp, in the documents folder from the applicationDidBecomeActive: app delegate method, and delete that file inside the applicationWillResignActive: method.

    Normally, the app should see no lock_file.tmp file in applicationDidBecomeActive: in the documents folder, because applicationWillResignActive: deletes it. If the app crashes, however, the file would remain there, so your program would be able to detect that the previous run has been interrupted due to a crash.