【问题标题】:Alamofire 5 - file download execution time (Swift 5)Alamofire 5 - 文件下载执行时间(Swift 5)
【发布时间】:2020-04-10 01:14:44
【问题描述】:

我刚刚将我的项目从 Alamofire 4 更新到 Alamofire 5 并在需要时更新了代码,但是我在参考文档或以前的帖子中找不到任何关于下载时间的帮助。

在以前的版本中,我使用了“response.timeline.totalDuration”,它提供了从请求开始到响应序列化完成的时间间隔(以秒为单位)。来自 (Checking response Time of API in iOS using Swift 3?)。

对于获取 Alamofire 5 方法的任何帮助将不胜感激。

【问题讨论】:

    标签: ios swift alamofire


    【解决方案1】:

    您现在应该使用response.metrics.taskInterval。这将返回一个 DateInterval,描述从网络请求发起到完成所用的时间。更多信息:https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#download-progress

    如果您想以秒为单位获得此持续时间,请尝试response.metrics.taskInterval.duration

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 2020-04-10
      • 1970-01-01
      • 2020-04-12
      • 2023-04-01
      • 2020-07-26
      • 1970-01-01
      相关资源
      最近更新 更多