iOS 11 triggers UISwitch value change action when `on` attribute is changed within the action handler (11b3 15A5318g)

Originator:felipekellermann
Number:rdar://33453656 Date Originated:July 21 2017
Status:Open Resolved:
Product:iOS + SDK Product Version:11.0b3 (15A5318g)
Classification:Serious Bug Reproducible:Always
 
Area:
UIKit

Summary:
When the UISwitch action handler for ValueChanged changes its own `on` property it triggers the action again which is not expected since iPhone OS 2 and it is exactly against what is documented. The problem isn't observed when the property is changed outside the ValueChanged action.

Steps to Reproduce:
1 - Open the attached project (SwitchTargetActionValue)

2 - Using iOS 10, 9, 8...: touch the switch and observe "Changes: 1" (the action is triggered once, as it expected).

3 - Using iOS 11.0b3 (15A5318g): touch the switch and observe "Changes: 2" (the action is triggered twice, which is a problem)

4 - Notice the behavior isn't observed then "Change" (button) changes the `on` property.

Expected Results:
See: https://developer.apple.com/documentation/uikit/uiswitch/1623686-seton?language=objc

"Setting the switch to either position does not result in an action message being sent."

Observed Results:
Exactly the opposite of "Setting the switch to either position does not result in an action message being sent.".

When the `on` property is changed within the ValueChanged action it is triggering the action changing a pretty old behavior.

Version:
11.0b3 (15A5318g)

Notes:


Configuration:


https://www.dropbox.com/s/t278os7dixtdmr1/Radar-33453656.zip?dl=0

Comments

The bug is still present in iOS 12.

By tomekwsrod at Feb. 1, 2019, 4:47 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!