Search code examples
xcode6option-typexcode6-beta7

Bound value in a conditional binding must be of Optional type in Xcode Beta 7, not in beta 6


This is my code:

if let myWindow: UIWindow = UIApplication.sharedApplication().keyWindow {
    window = myWindow
} else {
    window = myWindow2[0] as? UIWindow
}

It is throwing this exception at the first line (where it says if let):

Bound value in a conditional binding must be of Optional type

It was working in Beta 6 but I upgraded to beta 7 and now bam. does not work.

What must I do to clear the error?


Solution

  • As of Beta 7, keyWindow returns a UIWindow instead of a UIWindow! (it's no longer an optional) so you no longer need the if let.