Post

Replies

Boosts

Views

Activity

Reply to How to fix these errors?
I have defined aspectRatio here: struct ContentView: View {     let viewModel: EmojiMemoryGame     @State var aspectRatio = 1 Ps: I understand that is really hard to keep track of the code in this way but I do the possible to make it easy.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to How to fix these errors?
Yes I was responding to you. It seams that you changed something, I'm sorry. Now I have tried to put CardView(card: card).aspectRatio(2.0, contentMode: ContentMode.fit) into my code and then put @State before aspectRatio. So this the updated code: import SwiftUI struct ContentView: View {     let viewModel: EmojiMemoryGame     @State var aspectRatio = 1     var body: some View {         let emojis = ["😀", "😍", "🤪", "😱", "🥶", "🤑", "😡", "🤠", "🥳", "🤩", "🥴", "😴", "😪", "😶‍🌫️", "😈", "🤯", "🤐", "🤗"] //WARNING: Initialization of immutable value 'emojis' was never used; consider replacing with assignment to '_' or removing it. Replace 'let emojis' with '_'         var emojiCount = 4         VStack {             LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                 ForEach(viewModel.cards) { card in                     CardView(card: card).aspectRatio(2.0, contentMode: ContentMode.fit)                 }             }             .padding()             .foregroundColor(Color(.systemTeal))             Spacer()             Button {                 emojiCount += 1                 if emojiCount == 10 {                     aspectRatio = 9/3                 }                 if emojiCount > 17 {                     print("Card finished")                 }             } label: {                 Text("Add Card")             }         }     } } struct CardView: View {     let card: MemoryGame<String>.Card     var body: some View {         ZStack {             let shape = RoundedRectangle(cornerRadius: 20)             if card.isFaceUp {                 shape.fill().foregroundColor(.white)                 shape.stroke(lineWidth: 3)                 Text(card.content).font(.system(size: 50))             } else {                 shape.fill(.orange)             }         }     } } struct ContentView_Previews: PreviewProvider {         static var previews: some View {             ContentView(viewModel: game) //Cannot find 'game' in scope     } } Now it gives me one Warning and an Error :(
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to How to fix these errors?
Now I have defined it but despite it gives me the same errors Code: import SwiftUI struct ContentView: View {     let viewModel: EmojiMemoryGame     var body: some View {         VStack {                 LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                     ForEach(viewModel.cards) { card in                         CardView(card: card).aspectRatio(aspectRatio, contentMode: .fit) //Cannot convert value of type '(CGFloat?, ContentMode) -> some View' to expected argument type 'CGSize'                     }                 }                 .padding()                 .foregroundColor(Color(.systemTeal))                                  Spacer()                                  Button {                     emojiCount += 1                     if emojiCount == 10 {                         aspectRatio = 9/3                     }                     if emojiCount > 17 {                         print("Card finished")                     }                 } label: {                     Text("Add Card")                 }             }         }          } struct CardView: View {     let card: MemoryGame<String>.Card          var body: some View {         ZStack {             let shape = RoundedRectangle(cornerRadius: 20)             if card.isFaceUp {                 shape.fill().foregroundColor(.white)                 shape.stroke(lineWidth: 3)                 Text(card.content).font(.system(size: 50))             } else {                 shape.fill(.orange)             }         }              } } struct ContentView_Previews:     PreviewProvider {         static var previews: some View {             ContentView(viewModel: game) //Cannot find 'game' in scope     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to How to fix these errors?
It says me "Cannot find 'CardView22' in scope", maybe because we haven't defined the CardView22. This is EmojiMemoryGame: import SwiftUI class EmojiMemoryGame {     static let emojis = ["😀", "😍", "🤪", "😱", "🥶", "🤑", "😡", "🤠", "🥳", "🤩", "🥴", "😴", "😪", "😶‍🌫️", "😈", "🤯", "🤐", "🤗"]     static func createMemoryGame() -> MemoryGame<String> {         MemoryGame<String>(numberOfPairsOfCards: 4) { pairIndex in             emojis[pairIndex]         }     }     private var model: MemoryGame<String> = createMemoryGame()     var cards: Array<MemoryGame<String>.Card> {         model.cards     } } I have defined "game" here: import SwiftUI @main  struct MemorizeApp: App {     let game = EmojiMemoryGame()          var body: some Scene {         WindowGroup {             ContentView(viewModel: game)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Learning
Hello! I actually started with an edx course, then now I’m watching some videos on YouTube. Doing in this way my knowledge is growing. You can try with this and then go on. If you have passion you can do anything!
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’22
Reply to How to fix these errors?
I have defined aspectRatio here: struct ContentView: View {     let viewModel: EmojiMemoryGame     @State var aspectRatio = 1 Ps: I understand that is really hard to keep track of the code in this way but I do the possible to make it easy.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to How to fix these errors?
Yes I was responding to you. It seams that you changed something, I'm sorry. Now I have tried to put CardView(card: card).aspectRatio(2.0, contentMode: ContentMode.fit) into my code and then put @State before aspectRatio. So this the updated code: import SwiftUI struct ContentView: View {     let viewModel: EmojiMemoryGame     @State var aspectRatio = 1     var body: some View {         let emojis = ["😀", "😍", "🤪", "😱", "🥶", "🤑", "😡", "🤠", "🥳", "🤩", "🥴", "😴", "😪", "😶‍🌫️", "😈", "🤯", "🤐", "🤗"] //WARNING: Initialization of immutable value 'emojis' was never used; consider replacing with assignment to '_' or removing it. Replace 'let emojis' with '_'         var emojiCount = 4         VStack {             LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                 ForEach(viewModel.cards) { card in                     CardView(card: card).aspectRatio(2.0, contentMode: ContentMode.fit)                 }             }             .padding()             .foregroundColor(Color(.systemTeal))             Spacer()             Button {                 emojiCount += 1                 if emojiCount == 10 {                     aspectRatio = 9/3                 }                 if emojiCount > 17 {                     print("Card finished")                 }             } label: {                 Text("Add Card")             }         }     } } struct CardView: View {     let card: MemoryGame<String>.Card     var body: some View {         ZStack {             let shape = RoundedRectangle(cornerRadius: 20)             if card.isFaceUp {                 shape.fill().foregroundColor(.white)                 shape.stroke(lineWidth: 3)                 Text(card.content).font(.system(size: 50))             } else {                 shape.fill(.orange)             }         }     } } struct ContentView_Previews: PreviewProvider {         static var previews: some View {             ContentView(viewModel: game) //Cannot find 'game' in scope     } } Now it gives me one Warning and an Error :(
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to How to fix these errors?
I tried to copy and paste your code, but it's still not working. I really don't know how to figure out this
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to How to fix these errors?
Now I have defined it but despite it gives me the same errors Code: import SwiftUI struct ContentView: View {     let viewModel: EmojiMemoryGame     var body: some View {         VStack {                 LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                     ForEach(viewModel.cards) { card in                         CardView(card: card).aspectRatio(aspectRatio, contentMode: .fit) //Cannot convert value of type '(CGFloat?, ContentMode) -> some View' to expected argument type 'CGSize'                     }                 }                 .padding()                 .foregroundColor(Color(.systemTeal))                                  Spacer()                                  Button {                     emojiCount += 1                     if emojiCount == 10 {                         aspectRatio = 9/3                     }                     if emojiCount > 17 {                         print("Card finished")                     }                 } label: {                     Text("Add Card")                 }             }         }          } struct CardView: View {     let card: MemoryGame<String>.Card          var body: some View {         ZStack {             let shape = RoundedRectangle(cornerRadius: 20)             if card.isFaceUp {                 shape.fill().foregroundColor(.white)                 shape.stroke(lineWidth: 3)                 Text(card.content).font(.system(size: 50))             } else {                 shape.fill(.orange)             }         }              } } struct ContentView_Previews:     PreviewProvider {         static var previews: some View {             ContentView(viewModel: game) //Cannot find 'game' in scope     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to iOS 15.2.1
@Claude31 can you reply me, please?
Replies
Boosts
Views
Activity
Jan ’22
Reply to Where do I get the official apple logo files?
Try Option + Shift + K
Replies
Boosts
Views
Activity
Jan ’22
Reply to How to fix these errors?
It says me "Cannot find 'CardView22' in scope", maybe because we haven't defined the CardView22. This is EmojiMemoryGame: import SwiftUI class EmojiMemoryGame {     static let emojis = ["😀", "😍", "🤪", "😱", "🥶", "🤑", "😡", "🤠", "🥳", "🤩", "🥴", "😴", "😪", "😶‍🌫️", "😈", "🤯", "🤐", "🤗"]     static func createMemoryGame() -> MemoryGame<String> {         MemoryGame<String>(numberOfPairsOfCards: 4) { pairIndex in             emojis[pairIndex]         }     }     private var model: MemoryGame<String> = createMemoryGame()     var cards: Array<MemoryGame<String>.Card> {         model.cards     } } I have defined "game" here: import SwiftUI @main  struct MemorizeApp: App {     let game = EmojiMemoryGame()          var body: some Scene {         WindowGroup {             ContentView(viewModel: game)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to iOS 15.2.1
I was using 15.2 iOS version, and when I woke up it shows me this:
Replies
Boosts
Views
Activity
Jan ’22
Reply to XCode not installing
Hey! Can show a screenshot, because otherwise it’s a little different to understand the problem.
Replies
Boosts
Views
Activity
Jan ’22
Reply to Learning
Hello! I actually started with an edx course, then now I’m watching some videos on YouTube. Doing in this way my knowledge is growing. You can try with this and then go on. If you have passion you can do anything!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Job related queries
Hello, I link to you this page [https://www.apple.com/careers/us/) here you can see jobs opportunities at Apple. And the coding knowledge depends on what career you decide to choose.
Replies
Boosts
Views
Activity
Jan ’22
Reply to Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
I've updated the playground and now it's gone. Thank you anyway!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Where to put the animation
Thank you very much!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Difference between @ObservedObject, ObservableObject and @StateObject
ok thanks!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Keep face up the cards if equal
Where did you define the number of the cards?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22