gpt4 book ai didi

ios - AWS dynamodb 查询大多数时候崩溃

转载 作者:行者123 更新时间:2023-11-30 13:21:31 24 4
gpt4 key购买 nike

我正在尝试从 AWS DynamoDB 下载用户数据,如下所示:

func downloadUserData(id: String) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = true

let qe = AWSDynamoDBQueryExpression()
qe.hashKeyAttribute = "id"
qe.hashKeyValues = id

dynamoDBObjectMapper!.query(DDBUser.self, expression: qe).continueWithBlock { (task: AWSTask) -> AnyObject? in
if task.error != nil {
NSLog("🦁🦁🦁\(self)")
NSLog("🦁Fehler beim Laden der Userdaten: \(task.error)")
} else {
let paginatedOutput = task.result as! AWSDynamoDBPaginatedOutput
print("output \(paginatedOutput.items)")
for user in paginatedOutput.items as! [DDBUser] {
SessionController.sharedInstance.user = user
for (index, tacklId) in SessionController.sharedInstance.user.tacklIds.enumerate() {
if tacklId == "empty" {
SessionController.sharedInstance.user.tacklIds.removeAtIndex(index)
}
}
if !(SessionController.sharedInstance.user.endpoints.contains(SessionController.sharedInstance.currEndpoint!)) {
SessionController.sharedInstance.user.endpoints += [SessionController.sharedInstance.currEndpoint!]
}
}
NSLog("User Download Complete")
dispatch_async(dispatch_get_main_queue()) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
self.userdataDelegate?.userdataDownloadComplete!()
}
}
return nil
}
}

并非总是如此,但大多数时候,执行都会停在这一行:

 for user in paginatedOutput.items as! [DDBUser] {

使用此错误代码:

exc_breakpoint (code=1, subcode=0x10015d440)

甚至在禁用断点的情况下也会发生这种情况,并且我无法继续执行。

中断前的行:

print("output \(paginatedOutput.items)")

效果很好。问题是否可能出在另一个线程上,并且它错误地向我显示了此处的错误?如何最好地调试这个?谢谢

最佳答案

您正在尝试使用

let qe = AWSDynamoDBQueryExpression()
qe.hashKeyAttribute = "id"
qe.hashKeyValues = id

已弃用。我建议您改用“keyConditionExpression”和“expressionAttributeValues”。

谢谢,罗汉

关于ios - AWS dynamodb 查询大多数时候崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37731116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com