Record crashes

General func

func exceptionHandler(exception : NSException) {
  let defaults: NSUserDefaults = NSUserDefaults.standardUserDefaults()
 

    defaults.setObject(exception.debugDescription , forKey: "exception")
    defaults.synchronize()
  print("exc: \(exception)")
  print("exc call stack: \(exception.callStackSymbols)")
}

in didFinishLaunchingWithOptions

NSSetUncaughtExceptionHandler(exceptionHandler)
    if NSUserDefaults.standardUserDefaults().objectForKey("exception") != nil
    { .. }

create crash for example with

let array = NSArray()
let elem = array.objectAtIndex(99)

Tags: