Method: ProMotion::MotionTable::SectionedTable#accessory_toggled_switch

Defined in:
lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb

#accessory_toggled_switch(switch) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 71

def accessory_toggled_switch(switch)
  table_cell = switch.superview
  index_path = table_cell.superview.indexPathForCell(table_cell)

  data_cell = cell_at_section_and_index(index_path.section, index_path.row)
  data_cell[:arguments] = {} unless data_cell[:arguments]
  data_cell[:arguments][:value] = switch.isOn if data_cell[:arguments].is_a? Hash
  data_cell[:accessory_action] ||= data_cell[:accessoryAction] # For legacy support

  trigger_action(data_cell[:accessory_action], data_cell[:arguments]) if data_cell[:accessory_action]
end