Search code examples
swiftxcodeuikitxcode-storyboard

How do I check if passwords match in storyboard?


I am basically making a login page, and want to make sure that passwords match before I can enable the continue button. I looked at the storyboard intro on the Apple website, but I didn't really understand exactly how I can link my storyboard to code and check if the passwords match.


Solution

  • You don't, exactly. In your storyboard you'd connect the various fields in your user interface to IBOutlets (for connecting things, the nouns of your UX) and IBActions (for responding to user actions, the verbs) to your view controller.

    Fields like UItextField also can have a "delegate", an object that helps them manage their behavior. You'd hook up your view controller as a delegate of both of your password input fields, and when the passwords don't match, the view controller logic would disable the continue button.