I have just released my app on the App Store however I have just been emailed and told that there is issues with crashing.
The issue is with Alert Views which crash
Here is my drag and drop swift solution:
//Alerts change in iOS8, this method is to cover iOS7 devices
func CozAlert(title: String, message: String, action: String, sender: UIViewController){
if respondsToSelector("UIAlertController"){
var alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: action, style: UIAlertActionStyle.Default, handler:nil))
sender.presentViewController(alert, animated: true, completion: nil)
}
else {
var alert = UIAlertView(title: title, message: message, delegate: sender, cancelButtonTitle:action)
alert.show()
}
}
Call like this:
CozAlert("reportTitle", message: "reportText", action: "reportButton", sender: self)
Beware this is only for the most basic alerts, you might need additional code for advanced stuff.
I had the same problem in the relese build. It seems an internal bug of the swift compiler (using Xcode 6.0.1 (6A317) )
I solved actually with a objC helper class with this method:
+ (BOOL) checkIfClassExists:(NSString *)className {
id c = objc_getClass([className cStringUsingEncoding:NSASCIIStringEncoding]);
if (c != nil) {
return YES;
} else {
return NO;
}
}
called in my swift code with a bridge header
if ObjCFix.checkIfClassExists("UIAlertController") {
//iOS 8 code here
} else {
//iOS 7 code here
}