TablePrint is a tool designed for developers.
It prints tables of dictionaries in the debugger console.
- ✍️ Description
- 🖥 Examples
- 💻 How to use
⚠️ Requirements- 🐞 Known Issues
TablePrint simply comes with only one function that takes a dictionary:
func printTable(_ content: [AnyHashable : Any?])
You can throw in a dictionary with anything in it.
let book: [AnyHashable : Any?] = [
"title": "The iPhone Developer's Cookbook",
"author": "Erica Sadun",
"publish_date": Date(timeIntervalSince1970: 1261094400),
"price": 16.65
]
printTable(book)
+--------------+---------------------------------+
| Key | Value |
+--------------+---------------------------------+
| publish_date | 2009-12-18 00:00:00 +0000 |
| author | Erica Sadun |
| title | The iPhone Developer's Cookbook |
| price | 16.65 |
+--------------+---------------------------------+
let stringAttributes: [NSAttributedStringKey : Any?] = [
.foregroundColor : UIColor.red,
.kern : 1,
.link: URL(string: "https://apple.com/"),
]
printTable(stringAttributes)
+---------+----------------------------------+
| Key | Value |
+---------+----------------------------------+
| NSLink | https://apple.com/ |
| NSColor | UIExtendedSRGBColorSpace 1 0 0 1 |
| NSKern | 1 |
+---------+----------------------------------+
TablePrint is available as Swift Package.
https://github.com/lukaswuerzburger/table-print
- Swift 4+
- iOS 9+
- macOS 10.10+
- Xcode 9+
- #2 The column width is currently not limited. Long lines result in ugly line breaks that break the whole UI of the table.
- #1 Can't run on macOS command line tool.
Issues and pull requests are welcome.