79756695

Date: 2025-09-05 10:53:00
Score: 3
Natty:
Report link

@alex you got very close to answer but I found later that real culprit behind this was my call to that slider method. Here it was:

textOpacitySlider.addTarget(self, action: #selector(Opacity), for: .allEvents)

I am new to swift and I asked my manager that if calling for all events would be the issue, but he told me that it shouldn't create any mess but when I changed this to this:

textOpacitySlider.addTarget(self, action: #selector(Opacity), for: .touchDragInside)

It started working finely i.e. calling objc function only once! I think .allEvents was tracking

-When user touches slider
-When he changes it
-And when he left his finger up

That's why my method was being called thrice!

Reasons:
  • RegEx Blacklisted phrase (1.5): I am new
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @alex
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Muhammad Asad