Skip to content

Instantly share code, notes, and snippets.

@atierian
Created August 31, 2020 00:41
Show Gist options
  • Save atierian/c318752550455427a20a0fa55fba54a5 to your computer and use it in GitHub Desktop.
Save atierian/c318752550455427a20a0fa55fba54a5 to your computer and use it in GitHub Desktop.
Debug print all properties in an object in foo = bar form
public func mirrorPrint(_ object: Any, terminator: String = "\n") {
for child in Mirror(reflecting: object).children {
guard let label = child.label else {
Swift.print(child.value, terminator: terminator)
continue
}
Swift.print(label, "=", child.value, terminator: terminator)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment