Hello,
we tried to build the app from the lecture 1 of "Developing IOS 11 Apps with swift" with Paul Hegarty and we got this message. Can anybody help, please?
Thanks a lot.
Here is the code:
/
/
/
/
/
import UIKit
class ViewController: UIViewController
{
var flipCount = 0 {
didSet {
flipCountLabel.text = "Flips:\(flipCount)"
}
}
@IBOutlet weak var flipCountLabel: UILabel!
@IBOutlet var cardButtons: [UIButton]!
var emojiChoices = [" "," "," "," "]
@IBAction func touchCard(_ sender: UIButton) {
flipCount += 1
if let cardNumber = cardButtons.index(of: sender) {
flipCard(withEmoji: emojiChoices[cardNumber], on: sender) //Message: Use of local variable 'flipCard' before its declaration
} else {
print ("chosen card was not in cardButton")
}
func flipCard(withEmoji emoji: String, on button: UIButton){
if button.currentTitle == emoji {
button.setTitle("", for: UIControlState.normal)
button.backgroundColor = colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1)
} else {
button.setTitle(emoji, for: UIControlState.normal)
button.backgroundColor = colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
}
}
}
}