Square1 iOS Tools
我们 Swift 项目的方便助手、类型和技巧的集合。
索引
先决条件
- iOS 9.0+
- XCode 10+
- Swift 4.2+
安装
Cocoapods
如果您已经在项目中使用 Cocoapods,则可以直接跳到第 3 步
use_frameworks!
- 将此 Pod 添加到您的 Podfile 中
pod 'Square1Tools'
- 运行
pod install
- 您需要在希望使用 Pod 的每个文件上使用此导入
import Square1Tools
运行测试
- 下载源项目
- 按
Cmd + U
运行测试。
如何使用
查看文档页面。
Keychain
Keychain 是一个辅助类,用于快速访问 iOS Keychain 中的存储值。
您可以使用如下方式实例化 Keychain 对象
let keychain = Keychain()
// You can also instance it with a specific access group.
let anotherKeychain = Keychain(accessGroup: "MyGroup")
使用 Keychain 非常简单
// Save into keychain
keychain.save("Hello World!!", forKey: "MyKey") // returns true if ok, otherwise false
// Read from keychain
keychain.get("MyKey") // returns String?
// Delete from keychain
keychain.delete("MyKey") // returns true if ok, otherwise false
日志
Log 是一个用于更准确控制台打印的辅助方法。从 iOS 10 开始,我们使用 OSLog 类来打印日志。您可以使用 Mac 的控制台应用通过子系统过滤和管理日志。我们在调试模式下添加了更多的实用信息,如行、函数和表情符号。
更多信息请参阅 统一日志。
用法
Log("Default message with default OSLog")
let testLog = OSLog(subsystem: "S1.Square1ToolsApp.test", category: "test")
Log("Info message", log: testLog, type: .info)
贡献
请阅读 CONTRIBUTING 了解我们的行为准则以及向我们提交拉取请求的流程。确保您对修改和新的代码进行注释,并在提交拉取请求之前使用 Jazzy 生成新的文档。
作者
许可
本项目采用MIT许可协议 - 具体内容见LICENSE文件
致谢
向所有伟大的Swift社区成员致谢。