PlainPing 0.5.2

PlainPing 0.5.2

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最后发布2021 年 5 月

Jonas Schoch 维护。



PlainPing 0.5.2

PlainPing

一个非常简单的 ping 接口,用于 ping 域名或地址,用 swift 3.0 编写。该模块使用 SimplePing

*要使用 swift 2.2 版本,请选择标有 PlainPing 0.2.2 的源或 pod.*

使用方法

要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install

PlainPing 接口

PlainPing 中有一个类函数,调用 PlainPing.ping(hostname, completionBlock)

示例

PlainPing.ping("www.google.com", withTimeout: 1.0, completionBlock: { (timeElapsed:Double?, error:Error?) in
    if let latency = timeElapsed {
        self.pingResultLabel.text = "latency (ms): \(latency)"
    }

    if let error = error {
        print("error: \(error.localizedDescription)")
    }
})

参数

  • hostName: 使用名称或 IP 地址
  • completionBlock: 将返回 ms 中的耗时和错误,如果有
  • withTimeout: (可选),定义我们等待回答的秒数,默认 3 秒

要求

最低要求未知。已与以下版本进行测试

  • xcode 8.0
  • CocoaPods 1.0

安装

PlainPing 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "PlainPing"

作者

Jonas Schoch, [email protected]

许可证

PlainPing 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。