首页 > 解决方案 > 无法快速在分页输出中获得更多页面

问题描述

我需要帮助!我正在尝试将我的 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)
}

}

标签: swiftamazon-dynamodb

解决方案


推荐阅读