我试图像这样从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”。
谢谢,
罗汉