Skip to content

Instantly share code, notes, and snippets.

@tonnylitao
Last active July 2, 2020 10:07
Show Gist options
  • Save tonnylitao/8fa7e24e185c2a7c08ddf2ed5a308e3e to your computer and use it in GitHub Desktop.
Save tonnylitao/8fa7e24e185c2a7c08ddf2ed5a308e3e to your computer and use it in GitHub Desktop.
Tag KeyPath mapping
let mapping = [1 : \User.name,
2 : \User.email,
3 : \User.likeKiwi,
4 : \User.travel,
5 : \User.hiking,
6 : \User.reading]
func viewChanged(_ field: Field) {
let path = mapping[sender.tag]
model[keyPath: path] = field.value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment