Skip to content

Instantly share code, notes, and snippets.

@AndreyPanov
Created April 28, 2017 11:42
Show Gist options
  • Save AndreyPanov/9730707478a032ef2a51ac5d8638e17d to your computer and use it in GitHub Desktop.
Save AndreyPanov/9730707478a032ef2a51ac5d8638e17d to your computer and use it in GitHub Desktop.
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