swift - 无法快速在分页输出中获得更多页面
问题描述
我需要帮助!我正在尝试将我的 DynamoDB 读出到 Swift 中的 IOS 应用程序中。似乎 SDK 仅使用 PaginatedOutput 进行扫描。我无法获得分页输出来加载更多页面。Lastevaluatedkey 是一样的,没有更多的页面被加载。这是我的代码:---
func scan(){
let scanExpression = AWSDynamoDBScanExpression()
scanExpression.limit = 5000
let dynamoDBObjectMapper = AWSDynamoDBObjectMapper.default()
dynamoDBObjectMapper.objectMapperConfiguration.consistentRead = 0
dynamoDBObjectMapper.scan(Rplaces.self, expression: scanExpression).continueWith(block: { (task:AWSTask!) -> Any? in
self.paginatedOutput = task.result
DispatchQueue.main.async(execute: {
print("next " , self.paginatedOutput?.lastEvaluatedKey ?? "")
for item in self.paginatedOutput?.items as! [Rplaces] {
print("place ", item.id ?? 0)
}
})
if self.paginatedOutput?.lastEvaluatedKey != nil{
print("second loop " , self.paginatedOutput?.lastEvaluatedKey ?? "")
self.loadMoreResults()
}
return true
})
return
}
func loadMoreResults() {
paginatedOutput?.loadNextPage(completionHandler: {(error: NSError?) -> Void in
DispatchQueue.main.async(execute: {
print("next " , self.paginatedOutput?.lastEvaluatedKey ?? "")
for item in self.paginatedOutput?.items as! [Rplaces] {
print("place ", item.id ?? 0)
}
})
} as? (Error?) -> Void)
}
}
解决方案
推荐阅读
- ibm-cloud - Watson Discovery 可以从 IBM Cloud Object Storage 处理多少数据?
- html - 我想在不安装软件的情况下以 html 显示 Word 文件的内容。我怎样才能显示文件。我的网页上的 docs 或 .xlsx?
- outlook-web-addins - 我们可以更改用户代理以在 Edge 中运行 Outlook 插件而不是在 Outlook 中运行 IE
- multithreading - C 子线程如何通知主线程,而主线程仍在运行?
- django-rest-framework - 我正在尝试将我的 djangorest api contactsapp 部署到 heroku
- android - 在片段内获取共享视图模型时出错
- javafx - 带有进度指示器和 runLater 的 JavaFX runAsync
- r - 如果我只有关于哪个更接近一对值的数据,我如何近似一个“隐藏”值?
- python-3.x - 如何使用 nodemon 运行 python 3?
- authentication - 本地 S4Hana 中的出站 OAuth 连接可能吗?