Match App not displaying properly

Hi Code Crew, I’ve finished the Match App, I had so many errors which took me ages to iron out from the lesson sheets, finally it runs but does not display four cards across the screen and then comes up with this error after I close the App Simulator. Not sure how to fix this.

Generally when you get an error like that, there is some corresponding crash data in the Console window at the bottom.

In your screen shot, that window is not open so the crash data is not visible. Tap on the little window icon down the bottom right of the Xcode window (as indicated in the below image by the red arrow) to open that console (Debug) view and then go right to the top of the output to the initial error messages that are displayed. In there will be some details pointing you in the right direction.

If the messages don’t make any sense then copy and post the console output in a reply.

It is likely that there is a UI element in your storyboard that is no longer correctly linked to your swift file be that an IBOutlet or an IBAction.

I did see that but it didn’t make any sense.

Looks to be something to do with playing the sound effects. Do the sounds work at all or does it crash before you get to that point?

Some of the sounds work, appears to be when clicking the second card

OK so that’s just spurious output in the console then and nothing to do with the actual crash.

So you get the shuffle sound when it loads and then the sound when you tap the first card but then it crashes when you tap the second card?

yep I get all sounds, error appears when I click second card, App does not crash, I can play till the timer ends.

Wait, the error appears after you select the second card but you can still play till the timer ends?

Sort of, not always after clicking second card, sometimes the fourth card, and I only have three cards across the screen, all cards do display but in more rows.

What happens when you select an iPhone 11 as your simulator?

yeah I have four cards across with iPhone 11

OK that’s normal with a smaller device to get fewer cards across the display. The larger devices have more real estate to deal with so the collectionView can add more per row.

I still get the errors tho?

OK so what you are saying is that you don’t get a SIGTERM error where the App crashes but you are getting what appears to be errors in the Console (Debug) area. Is that right?

Yes, App works fine, timer runs to the end, wether I win or lose and the error opens after I close the simulator.

Oh now I know what you are doing. OK if you close the simulator with the code still running from Xcode you will cause a crash because your are disconnecting Xcode from the Simulator by closing the Simulator. There is no need to close the simulator after running the App. Just stop the App from within Xcode by tapping on the stop button to the right of the run button.

ok. But I’m also still getting errors down the bottom as I click cards, first error appears when I open the App.

So they are the errors you are referring to in the Console? ie as per this image you posted earlier?

yes that is correct …

OK, can you copy your code from the SoundManager file starting at the import statement and right to the last line.

Paste that in a reply by putting three back-ticks (```) on a blank line first. (The back-tick character is just below the tilde symbol ~ on your keyboard).

Then on the next line paste your code and then on the next blank line place another 3 back-ticks. This will format your code nicely in a reply.