Created
April 28, 2017 11:42
-
-
Save AndreyPanov/9730707478a032ef2a51ac5d8638e17d to your computer and use it in GitHub Desktop.
This file contains 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
func perform<T>(with identifier: String, closure: (T) -> Void) { | |
Mirror(reflecting: self).children.forEach { property in | |
guard | |
property.label?.contain(identifier) == true, | |
let value = property.value as? T | |
else { return } | |
//run closure | |
closure(value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment