B. The sliderChanged method must have a parameter for the sender
C. minimumValue and maximumValue must be integers
D. addTarget method is missing the event type
Solution
Step 1: Check method signature for target-action
The action method for UISlider must accept the sender parameter (usually UISlider) to match the selector signature.
Step 2: Verify other parts
minimumValue and maximumValue are Float, so integers are allowed as they convert. UISlider can be created without frame in code. addTarget includes event type .valueChanged correctly.
Final Answer:
The sliderChanged method must have a parameter for the sender -> Option B
Quick Check:
Action method needs sender parameter [OK]
Hint: Action methods need sender parameter for UIControl events [OK]
Common Mistakes:
Omitting sender parameter in action method
Thinking min/max must be Int instead of Float
Assuming UISlider requires frame on creation
Missing event type in addTarget
5. You want to create a UISlider that only allows values between 1 and 5, starting at 3, and prints "Selected: x" whenever the value changes. Which code snippet correctly implements this behavior?