Skip to content

Instantly share code, notes, and snippets.

@jhandguy
Last active May 2, 2019
Embed
What would you like to do?
Accessible
protocol Accessible {
func generateAccessibilityIdentifiers()
}
extension Accessible {
func generateAccessibilityIdentifiers() {
#if DEBUG
let mirror = Mirror(reflecting: self)
for child in mirror.children {
if
let view = child.value as? UIView,
let identifier = child.label?.replacingOccurrences(of: ".storage", with: "") {
view.accessibilityIdentifier = "\(type(of: self)).\(identifier)"
}
}
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment