0

I'm implementing my custom state saving, and I just wanted to check if my app has crashed the last time a user use it.

What i thought was this: to wrap the whole main function in @try-catch block and if something is catched to just write something in user defaults.

But is this good idea, or it's bad for the app itself?

Devfly
  • 2,495
  • 5
  • 38
  • 56
  • 1
    How about fixing your code instead so that it doesn't crash? –  Dec 15 '12 at 13:26
  • The key here is if the app has crashed for some unknown reason, to start the state over with the first view controller, not restore and restore infinitely the crashing view controller, and my app to just keep crashing. – Devfly Dec 15 '12 at 13:31
  • There's nothing wrong with a try/catch in an iOS main. It's used in [this scheme](http://stackoverflow.com/a/12268397/581994) to present the exception stack trace on the simulator and works well. – Hot Licks Dec 15 '12 at 13:34
  • 1
    I do recommend though, that you use the ObjC version of @try-catch: `NS_DURING, NS_HANDLER, NS_ENDHANDLER`. Or stop trying to reinvent the wheel and use PLCrashReporter. – CodaFi Dec 15 '12 at 15:06
  • Consider using [PLCrashReporter](http://code.google.com/p/plcrashreporter/) – rmaddy Dec 15 '12 at 16:58

1 Answers1

0

You can do this, but note that user defaults are not for storing error information. So its not a good idea.

Are you developing for iOS or Mac OS X?