Last active
July 2, 2020 10:07
-
-
Save tonnylitao/8fa7e24e185c2a7c08ddf2ed5a308e3e to your computer and use it in GitHub Desktop.
Tag KeyPath mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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