100 days of swiftui: 22
https://www.hackingwithswift.com/100/swiftui/22
Here are three ways you should try extending this app to make sure you fully understand what’s going on:
@State private var score = 0
// ...
func guessFlag(selectedAnswer: Int) {
if selectedAnswer == selectedCountry {
result = "Correct"
score += 10
} else {
result = "Wrong"
score -= 10
}
showingScore = true
}
코드 파일
https://github.com/treesofgroo/Ios-GuessFlags/commit/0f845c68de270a3a108eb1392a8764eb8309e9a9
func guessFlag(selectedAnswer: Int) {
if selectedAnswer == selectedCountry {
result = "Correct! It's the flag of \(countries[selectedAnswer])"
score += 10
} else {
result = "Wrong! That's the flag of \(countries[selectedAnswer])"
score -= 10
}
showingScore = true
}
코드 파일
https://github.com/treesofgroo/Ios-GuessFlags/commit/41d409b3b57bcb76b29d911f740b1dcf3afdc931
questionStatus
설정하기코드 파일
https://github.com/treesofgroo/Ios-GuessFlags/commit/42ac001cebd80a7004a3df97930d4087f28584c9
오타 수정 (최종)
https://github.com/treesofgroo/Ios-GuessFlags/commit/19baa4a5b0f044f2c03b49480841888cabb7cf54
완성 화면
첫 문제, 문제 중, 마지막 문제 후