Post

Replies

Boosts

Views

Activity

How to fix these errors?
Hello there! I want to create a cards game, and I'm creating it following the Stanford University's tutorial. I followed the video step by step but there is a warning that In the video doesn't appear. Can someone help me to fix it? Here's the link of the video: [https://www.youtube.com/watch?v=oWZOFSYS5GE&t=671s) This is my code: import SwiftUI struct ContentView: View {     var emojis =["🚲","🚂","🚁","🚜","🚕","🏎","🚑","🚓","🚒","🚁","🚀","⛵️","🛸","🛶","🚌","🛺","🚇","🚠","🦽","🚗","🚚","🛴","🛵","🚅"]   @State  var emojiCount: Int = 4    var body: some View {         ScrollView {             LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                 HStack {                     ForEach(emojis[0..<emojiCount], id: \.self, content: { emoji in                         CardView(content: emoji).aspectRatio(2/3, contentMode:.fit)                     })                 }             }             .foregroundColor(/*@START_MENU_TOKEN@*/.red/*@END_MENU_TOKEN@*/)         }         Spacer()         HStack {             remove             Spacer()             add         }         .font(.largeTitle)         .padding(.horizontal)     } } var remove: some View {     Button {         if emojiCount > 1 { // here's the first error which says "Cannot find 'emojiCount' in scope'"             emojiCount -= 1 // here's the same error which says "Cannot find 'emojiCount' in scope'"         }     } label: {         Image(systemName: "minus.circle")              } } var add: some View {     Button {         if emojiCount < emojis.count { // here's the same error which says "Cannot find 'emojiCount' in scope'"             emojiCount += 1 // here's the same error which says "Cannot find 'emojiCount' in scope'"         }     } label: {        Image(systemName: "plus.circle")     } }          struct CardView: View {         var content: String         @State var isFaceUp: Bool = true                  var body: some View {             ZStack {                 let shape = RoundedRectangle(cornerRadius: 8)                 if isFaceUp {                     shape.fill(.white)                     shape.strokeBorder(lineWidth:3).foregroundColor(.blue)                     Text(content).font(.largeTitle)                 } else {                     shape.fill(.blue)                 }             }             .onTapGesture {                 isFaceUp = !isFaceUp             }         }     }                                                                                                    struct ContentView_Previews: PreviewProvider {         static var previews: some View {             ContentView()                 .preferredColorScheme(.dark)         }     }
4
1
497
Oct ’22