Xcode : Compare buttons : I am new to iOS development and I was trying to make a basic tic tac toe app.
I am not able to find a way to compare the value of three buttons(the one's in a row or column etc). I managed to create 9 buttons and I am replacing the image of each button on user click(Either X or O based on turn.) Also i am using tag id from 1-9 on buttons.

Here the code I am facing an error in.

      func check(){
            let b1 = self.view.viewWithTag(1) as? UIButton
            let b2 = self.view.viewWithTag(1) as? UIButton
            let b3 = self.view.viewWithTag(1) as? UIButton
            let b4 = self.view.viewWithTag(1) as? UIButton
            let b5 = self.view.viewWithTag(1) as? UIButton
            let b6 = self.view.viewWithTag(1) as? UIButton
            let b7 = self.view.viewWithTag(1) as? UIButton
            let b8 = self.view.viewWithTag(1) as? UIButton
            let b9 = self.view.viewWithTag(1) as? UIButton
            if(b1.currentImage.isEqual(UIImage(named: "x")) && b2.currentImage.isEqual(UIImage(named: "x")) && b3.currentImage.isEqual(UIImage(named: "x")))
            {
                print("X wins")
            }
        }

I am getting an Error on if statement saying,

> Value of optional type 'UIButton?' not unwrapped; did you mean to use
> '!' or '?'?

Now the problem is the inbuilt help is not fixing the error. Also I do not understand why am I getting this error. Can someone help me explain why I am facing this error? Also how to fix it?