Update on MatchApp Game


First of all, I just want to thank Chris and Team for a wonderful job on the free IOS training! I have finished the 29 day challenge and want to add an additional reset button that will reset that whole status of the game to its original state.

I am coming from a embedded C background, which in our case, just going back to main() to start all over again.

I tried to invoke the viewDidLoad again, but to to avail. Can you give some advice/recommendation on this?

Just want to get this over before moving forward with another build.


Hi, good idea! I also wanted to add that button, Chris, how do we do it?

you can try to simply put an alert and have the values (all arrays “reset”)

model = CardModel()
cardArray = [ Card ] ()
cardArray = model.getCards()
seconds = 45

Where do you put this code?

depends, you can put it on the win check or if time is 0
also make sure to repeat/refresh the timer when you do it

Thanks! I’ll try this one and will be back for an update

I added this inside the show alert after the game has ended. Timer is stuck at zero. What is the simplest way to call viewDidLoad again to reinitialize everything?

    // Add a button for the user to dismiss
    let okAction = UIAlertAction(title: "OK", style: .default, handler: { ACTION in
        let model = CardModel()
        self.deckOfCards = [Card]()
        self.deckOfCards = model.getCards()
        self.milliseconds = 60 * 1000

just invalidate the timer and put in the code again inside your action