I have a delete button on a cell and it was crashing my app in iOS7 but not in iOS8. I later found out the crash was caused by by how deep down I was digging into my view hierarchy.
To make things clearer here is the code that solved the issue:
func didTapDeleteButton(sender: UIButton) {
var cell: HoursOfOperationTableViewCell!
if let gotModernAlert: AnyClass = NSClassFromString("UIAlertController") {
println("UIAlertController can be instantiated")
//make and use a UIAlertController
cell = sender.superview?.superview? as HoursOfOperationTableViewCell
}
else {
println("UIAlertController can NOT be instantiated")
cell = sender.superview?.superview?.superview? as HoursOfOperationTableViewCell
}
As you can see I have to go further down into my view hierarchy to get to my custom cell view in iOS 7.
I was wondering if there was a more efficient way of checking the iOS version?
If I don't check then my app crashes in iOS7 if I leave the code like this:
cell = sender.superview?.superview? as HoursOfOperationTableViewCell
Thanks for your time.