if statement - Tic Tac Toe in swift - Winning line -


i followed tut me build tic tac toe game keep learning swift. in doing wanted add winning slashes whatever combination wins.

in code have

let winningcombinations = [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] 

these buttons tags.

i have created labels color bars no text slashes. connected them 1

@iboutlet weak var linefirstrow: uilabel!  

then hid label on storyboard.

i have been trying things like

let linerowone = [0, 1, 2]  if linerowone = true {  linefirstrow.ishidden = true } else {  linefirstrow.ishidden = false } 

i know not correct.

not entirely sure you're trying achieve, suspect solution on this:

let winningcombinations = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]  let lineone = [0, 1, 2]  if winningcombinations.contains(where: { $0 == lineone }) {     // stuff } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -