Learn Courses My Dashboard

Conditional Alerts IOS 15

Hi All,

I’m trying to develop an app right now that incorporates a login system, however I’m running into an issue where I want to be able to let the user know if the login details they inputted were incorrect. I thought of using Alerts however I can’t find much information on them that’s up to date and can’t really find anything that would allow them to be triggered within a function.

If anyone has any ideas on this I’d be very much appeciative.

What framework are you using, UIKit or SwiftUI?


OK what code do you have in your View at this point?

You could use alerts but I would include a Text() view below the Login fields that show an error which you would populate if you use some logic in a function that validates the login details and if invalid populates an error message property and then display that message in the Text like this, for example:


I hope that gives you an idea of how to do it. If not then I’m happy to provide some boiler plate code to help you out such that it makes sense.

Ok, yea that makes sense, and is probably the easier way to do it, thanks!

1 Like