Hi I have a game and it has 5 lines of words, and i want to check their validity, and then it flashes up a message saying "WORD: 5 point" or "WROD: Invalid" etc
I have a button with the following code (as you can see i have tried a delay)
func calcButton() {
//Do the across calculations and total points
for i in (0...4) {
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
self.acrossCalc(lineNo: i)
}
}
}
This then calls this fucntion
func acrossCalc(lineNo:Int) {
testWord = ""
wordCheck.removeAll()
for k in (lineNo * 7...lineNo * 7 + 6)
{
if (showLetters[k] != "!") {
if (showLetters[k]) != "?" {
testWord = testWord + showLetters[k]
wordCheck.append(showLetters[k])
}
}
}
wordCalc()
}
and then wordCalc() checks the word and flashes the message.
The problem i have is that it checks all 5 lines instantly, and flashes the message for the last one only.. I need each word checked and message shown, then the next etc....i have tried the above DispatchQueue, but that failed. Maybe i need something elsewhere to allow each word to be checked with enough time to display the message.
Any suggestions please?