Skip to content

Instantly share code, notes, and snippets.

@daniloc
Created May 14, 2019 19:49
Show Gist options
  • Save daniloc/06fc4bbf36510f0045a3fd7f9bc08684 to your computer and use it in GitHub Desktop.
Save daniloc/06fc4bbf36510f0045a3fd7f9bc08684 to your computer and use it in GitHub Desktop.

Revisions

  1. daniloc created this gist May 14, 2019.
    16 changes: 16 additions & 0 deletions Handling_Controls.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    @IBAction func handlePuppySwitch(_ sender: UISwitch) {

    let updateIndexPaths = [IndexPath(row: 0, section: TableSections.dynamicSection.rawValue)]

    if (sender.isOn) {
    puppyLabel.text = "Puppy Enabled"

    dynamicContent.insert("Puppy is on!", at: 0)
    tableView.insertRows(at: updateIndexPaths, with: .bottom)
    } else {
    puppyLabel.text = "Puppy"

    dynamicContent.remove(at: 0)
    tableView.deleteRows(at: updateIndexPaths, with: .left)
    }
    }