My app works perfectly the first time it is used but when returning to the start after playing the game and playing another it does some random things. I figure it is because the app still retains the previous game in it’s memory allocation? My question is, what is the best way programmatically to have an app start fresh and not have to quit it and open it again?
This is an app/game you developed, right? If so, it's something you've done, not the system storing your previous game in its 'memory allocation'.
Your app is reloading a previous game, or you've failed to wipe the game data from memory after you finished the game, so starting again simply plays from where you left off.
It's your issue to fix. You need to architect the app better.
The app is loading new data okay and not showing any of the previous game. A view will disappear randomly and show the previous View (not previous game View). I am hoping someone knows a way of starting an app from fresh irrespective of it’s architecture.
Before you re-launch your game, swipe up and up view the app switcher. The screen displayed there is a snapshot the system took the last time just before the game was suspended by the system. On re-launching the game, the system will display that snapshot until the app has relaunched. Since this happens very quickly it is usually just a very short flash.
I believe you can set the snapshot to whatever you want before the app is suspended, but you'll have to read up on how to do that.
Can you record the screen and show us exactly what you're seeing? Your explanation doesn't really explain it well.
Thank you for taking your time to help with this. I have tried your suggestion but I probably need to stress that the app does not crash but just has a problem of a random current View disappearing to show the previous View that contains a Button that opened it. In my app I made sure that after each round a user has to start from the beginning again. This is where I was hoping to do a reset. From my investigations I know you are not allowed to force quit an app programmaticall. I also understand my app is overweight so maybe I need to wait until I redo it starting with what I have learnt from you.
It seems that “Abandoned Memory” may be my issue. Unfortunately Playgrounds on an IPad does not allow me to do this. I need to have Xcode on a Desktop or Laptop to it.
I think I have a bit of work to do!!
I have built my app using this method (@ObservableObject & @ObservedObject) quite extensively which apparently causes problems very similar to what I am experiencing.