Alert support for iOS 7.1
troystribling opened this issue · 2 comments
Right now I struggle with backward compat, I must run on 7.1.
Your code uses alert messages this way:
self.presentViewController(UIAlertController.alertOnError(error), animated:true, completion:nil)
with an extension to the UIAlertController.
This function returns an UIAlertController.
It does not exist on iOS7
So, I get a dyld error: Symbol not found: OBJC_CLASS$_UIAlertAction
My solution would be:
var device : UIDevice = UIDevice.currentDevice()!;
var systemVersion = device.systemVersion;
var iosVerion : Float = systemVersion.bridgeToObjectiveC().floatValue;
if(iosVerion < 8.0) {
let alert = UIAlertView()
alert.title = "Error"
alert.message = error.localizedDescription
alert.addButtonWithTitle("OK")
alert.show()
}else{
var alert : UIAlertController = UIAlertController(title: "Error",
message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style:.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
But I can't return a UIAlertView and a UIAlertController with the same methods you use
in your code.
Suggestion, I would change all your calls to
self.presentViewController(UIAlertController.alertOnError(error), animated:true, completion:nil)
to a central notification object or something.
Suggestions?
I central object that handles both versions is the way to go.
Closing because support for iOS 7.1 no longer a requirement.