We help IT Professionals succeed at work.

Toggling a Switch's state from a Button in IOS Swift

Last Modified: 2020-06-21

In IOS Swift programming, if I have a SWITCH, I can make it Action or Outlet.

If I make the SWITCH an ACTION, I cannot set its STATE from another button because there is no VALUE parameter to get a handle on and set.

If I make a SWITCH an OUTLET, I can SET the Switch State from another point, but I cannot take action based on setting that switch because an OUTLET does not have an action func

How can I get around this situation?

1. Click the BUTTON: Update the text property of a field AND change the STATE of the button
2. Click the BUTTON:  Update the text property of a fieldswitches-and-buttons.png
Watch Question

Developer, Administator and Railway Track Engineer (yep you read that right)
This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.