UIAlertView stürzt App auf iOS 7 ab

Ich habe meine App gerade im App Store veröffentlicht. Ich wurde jedoch gerade per E-Mail darüber informiert, dass es Probleme mit Abstürzen gibt.

Das Problem sind Warnmeldungsansichten, die meine App zum Absturz bringen, wenn sie angezeigt werden sollen (nur in iOS 7). Ich hatte einen Code, der dieses Problem beheben sollte, aber in bestimmten Versionen von iOS 7 scheint er nicht zu funktionieren.

Hier ist mein aktueller Code:

@IBAction func resetAllButton(sender : AnyObject) {
    //If statement to check whether the modern style alert is available. Prior to iOS 8 it is not.
    if let gotModernAlert: AnyClass = NSClassFromString("UIAlertController") {

        println("UIAlertController can be instantiated")

        var alert = UIAlertController(title: "Start Over", message: "Are you sure you want to start over? This will erase your budget and all transactions.", preferredStyle: UIAlertControllerStyle.Alert)
        alert.addAction(UIAlertAction(title: "I'm sure!", style: UIAlertActionStyle.Default, handler:{ (ACTION :UIAlertAction!)in
            self.resetView()
        }))
        alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))

        self.presentViewController(alert, animated: true, completion: nil)
    }
    else {

        println("UIAlertController can NOT be instantiated")

        var alertView = UIAlertView()
        alertView.delegate = self
        alertView.title = "Start Over"
        alertView.message = "Are you sure you want to start over? This will erase your budget and all transactions."
        alertView.addButtonWithTitle("I'm sure!")
        alertView.addButtonWithTitle("Cancel")
        alertView.show()
    }
}

Was kann ich tun, um sicherzustellen, dass meine App auf keiner Version von iOS 7 oder 8 abstürzt?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage