Bird
0
0

You want to create a login form with a SecureField for password and a TextField for username. How do you ensure the password input is hidden while username is visible?

hard📝 Application Q8 of 15
iOS Swift - User Input and Forms
You want to create a login form with a SecureField for password and a TextField for username. How do you ensure the password input is hidden while username is visible?
AUse TextField for password and SecureField for username.
BUse SecureField for both username and password.
CUse TextField for both and set .secureTextEntry modifier on password field.
DUse SecureField for password and TextField for username with separate @State variables.
Step-by-Step Solution
Solution:
  1. Step 1: Choose correct input fields

    SecureField hides input, suitable for password; TextField shows input, suitable for username.
  2. Step 2: Use separate @State variables

    Each field binds to its own @State variable to store input separately.
  3. Final Answer:

    Use SecureField for password and TextField for username with separate @State variables. -> Option D
  4. Quick Check:

    SecureField hides password, TextField shows username [OK]
Quick Trick: Use SecureField only for sensitive inputs like passwords [OK]
Common Mistakes:
  • Using SecureField for username
  • Using TextField for password without masking
  • Sharing one @State variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes