Skip to content

Instantly share code, notes, and snippets.

@lachlanagnew
Last active October 16, 2018 03:32
Show Gist options
  • Select an option

  • Save lachlanagnew/690727ff37a36ba49653a42145bcc27c to your computer and use it in GitHub Desktop.

Select an option

Save lachlanagnew/690727ff37a36ba49653a42145bcc27c to your computer and use it in GitHub Desktop.
@IBAction func onChangeSelection(_ sender: Any) {
let COLORS = ["ff0000","00ff00","0000ff"]
let selection = selectionSegment.selectedSegmentIndex
let color = COLORS[selection]
let ref = Firestore.firestore().collection("settings").document("device1")
ref.setData([
"status": selection,
"color": color
]){ err in
if let err = err {
print("Error writing document: \(err)")
} else {
print("Document successfully written!")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment