【问题标题】:Lazy loading API requests in UITableview using Alamofire使用 Alamofire 在 UITableview 中延迟加载 API 请求
【发布时间】:2017-04-14 05:30:18
【问题描述】:

我是 swift 和 iOS 开发的新手。我想在我的UITableView 中有 100 个单元格,每个单元格都有一个不同的 API 请求,它返回 JSON 数据,我将保存到 CoreData 然后显示在 UITableView 中。我该如何处理?我想实现延迟加载,但我不知道在这种情况下该怎么做。请指出正确的方向。

【问题讨论】:

  • 在 Swift 中查看有关 DispatchGroupsasyncTasks 的信息。但是每个 UITableView 有 100 个请求真的很奇怪

标签: ios swift swift3 alamofire


【解决方案1】:

您可以在 main_queue 中加载表格视图

//Use swift 2.3
dispatch_async(dispatch_get_main_queue(), { () -> Void in
    self.yourTableView.reloadData()
})

//Use swift 3
DispatchQueue.main.async{
    self.yourTableView.reloadData()
}

【讨论】:

    猜你喜欢
    • 2015-11-01
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2012-05-23
    • 1970-01-01
    • 2011-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多