Kashif
Kashif

Reputation: 4632

UIVisualEffectView in iOS7

Below line of swift code works fine on iOS8 devices and simulators but on iOS7 simulator, gives EXC_BAD_ACCESS(code=1,address=0.x20) error with (lldb) in log.

var blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light))

EDIT: Since this class is not available in iOS7, I have put this declaration inside an if block and only run it if iOS version is 8+ but now it throws unresolved identifier error elsehwere in the code where i am trying to remove this blur effect view (even though, I am checking if it was created):

if iosVersion >= 8 {
   blurEffectView.removeFromSuperview()
}

Upvotes: 1

Views: 1945

Answers (1)

Kashif
Kashif

Reputation: 4632

The solution as guided by @gabbler was to declare it optional as AnyObject. Then conditionally (if iOS8) change it to UIVisualEffectView.

Upvotes: 1

Related Questions