Add a tag
to each switch. Don't wait for the view to be closed, add a target
and action
to each of your switches and handle the value change. When the value changes, use the tag
to determine which switch changed and save that data immediately.
The tag
could be an index into an array of switch identifiers...