I have a game where when you finish a level. You have the option to replay that level. So i programmatically created a replay level button to appear when the level is complete, and i told it to perform the selector replay level when touchupinside. And in my replay level method i was basically just going to perform a segue to the level, so as to basically reset everything in that vc. however normally when i programatically perform segues i make a vc segue to another vc, and give it an identifier and perform it. Yet, how in the world would i be able make a segue from my vc to itself?
Share
You should not be trying to reset a view controller by “segueing to itself”, (which in effect means deallocate and reallocate the VC’s memory), what you should be doing is resetting the main game loop and setting all values back to some default when the level is restarted. From a purely technical standpoint, it is simply not possible either. A navigation controller (which I will assume you are using considering you can successfully change view controllers), manages a stack of view controllers, which when mutated either deallocates, or retains pointers to its view controllers. In effect, you would be asking your VC object in the array to auto-refresh itself without some nasty memory management problems.