Polishing the Wheel


I am “making” an app with a log in screen, and using Parse as the back end, though this works for any login situation. I wanted a simple way to dismiss multiple view controllers using only code. The key word is “simple”. For some reason I was being stubborn and didn’t want to use a navigation controller. Why? Just because I didn’t. As Bobby Brown would say, “It’s my prerogative!” Is this the equivalent of wasting time on something I really didn’t need to? Yes. Then why do it? Because sometimes a rabbit hole needs to be explored.

Finding the needed code was more difficult than expected. There are MANY tutorials that explain how to create an unwind segue on the controller you want to go back to, and then connect that via a button on the view controller you are coming from. That almost works, except for the darn button. BUTTON!!! I need mine to run in CODE if the signup completes successfully. Having the user click a button will not work. (The user has the ability to back out of the page it they decide not to sign up, or it it fails at the time. Manually backing out after success seems awkward)

After about another hour of searching for this incredibly specific thing, I took a step back and realized I already knew how how to do this. The answer was so simple it was disgusting. Here it is… Follow the tutorial about creating the button. Remove the text from the button using the inspector, and disable the button in the viewWillAppear method. Boom, done. You can still access the unwind segue by using its assigned name.

I may not have used the “proper” way, but I did find a way. It works for now, and I am no longer beating my head against something harder than my head. Time to go see if I can learn more!

, , ,