Tuesday, September 27, 2022
HomeiOS Developmentios - I wrote a code precisely the identical as the trainer...

ios – I wrote a code precisely the identical as the trainer in CS193p 2021 Lesson 3, however I preserve getting the error “Can not discover ‘playing cards’ in scope” in Mannequin

[ad_1]

Viewmodel


import SwiftUI

class EmojiMemoryGame {
    static let emojis = ["🚂", "🚀","🚁", "🚔", "🦽", "🦼", "🚲", "🛴", "🛺", "🏍", "🛵", "🚍", "🚘", "🚖", "🚃", "🚋", "🚈", "🚊", "🚄", "🚝", "🚆", "🛸", "🛥", "⛴"]
    static func createMeormoryGame() -> MemoryGame<String> {
        MemoryGame<String>(numberOfPairsOfCards: 4) { pairIndex in 
            emojis[pairIndex]
        }
    }
    personal var mannequin: MemoryGame<String> = createMeormoryGame()
    var playing cards: Array<MemoryGame<String>.Card> {
            return mannequin.cads
        }
}

Mannequin


import Basis

struct MemoryGame<CardContent> {
    personal(set) var cads: Array<Card>
    
    func chooese(_ card: Card) {
        
    }
    init(numberOfPairsOfCards: Int, createCardContent: (Int) -> CardContent){
        playing cards = Array<Card>()
        // add numberOfPairCard x 2 playing cards to playing cards arry
        for pairIndex in 0..<numberOfPairsOfCards{
            let content material = createCardContent(pairIndex)
            playing cards.append(Card(content material: content material))
            playing cards.append(Card(content material: content material))
        }
    }
    struct Card {
        var isFaceUp: Bool = true
        var isMatched: Bool = false
        var content material: CardContent
    }
}

I can not discover the answer, please assist me
Ps. I’m utilizing iPad swift playgrounds to jot down the code, I’m not certain if this would be the reason for the error, I would not have a macOS machine

[ad_2]

RELATED ARTICLES

Most Popular

Recent Comments