TablePrint 0.2

TablePrint 0.2

Lukas Würzburger维护。



  • Lukas Würzburger

TablePrint

TablePrint是为开发者设计的工具。它可以将字典表打印到调试控制台。

内容

✍️描述

TablePrint仅包含一个函数,该函数接受一个字典

func printTable(_ content: [AnyHashable : Any?])

🖥示例

1. 书籍详情

您可以将任何内容放入字典中。

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                           |
+--------------+---------------------------------+

2. 字符串属性

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在Cocoapods上可用。只需在您的Podfile中放入以下行:

    pod 'TablePrint'

⚠️要求

  • iOS 9+
  • macOS 10.10+
  • Xcode 9+

🐞已知问题

  • #2 目前列宽未受限制。长行的换行可能导致整个表格UI中断。
  • #1 无法在macOS命令行工具上运行。

💪贡献

欢迎提交问题和pull请求。