Bird
0
0

You want a Stepper that starts at 10, goes up to 50, and increases by 5 each tap. Which code correctly sets this behavior?

hard📝 Application Q15 of 15
iOS Swift - User Input and Forms
You want a Stepper that starts at 10, goes up to 50, and increases by 5 each tap. Which code correctly sets this behavior?
AStepper(value: $count, in: 10...50, step: 10) { Text("Count: \(count)") }
BStepper(value: $count, range: 10...50, step: 5) { Text("Count: \(count)") }
CStepper(value: $count, in: 10...50, step: 5) { Text("Count: \(count)") }
DStepper(value: $count, in: 10...50) { Text("Count: \(count)") }
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct Stepper parameters

    To set step size, use the step: parameter. The range uses in:.
  2. Step 2: Check each option

    Stepper(value: $count, in: 10...50, step: 5) { Text("Count: \(count)") } correctly uses value: $count, in: 10...50, and step: 5. Stepper(value: $count, range: 10...50, step: 5) { Text("Count: \(count)") } uses wrong parameter range. Stepper(value: $count, in: 10...50) { Text("Count: \(count)") } misses step size. Stepper(value: $count, in: 10...50, step: 10) { Text("Count: \(count)") } uses wrong step size 10.
  3. Final Answer:

    Stepper(value: $count, in: 10...50, step: 5) { Text("Count: \(count)") } -> Option C
  4. Quick Check:

    Use in: range and step: size [OK]
Quick Trick: Use step: to set increment size in Stepper [OK]
Common Mistakes:
  • Using wrong parameter name 'range' instead of 'in'
  • Forgetting to set step size
  • Setting wrong step size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes