AWS dynamodb Query大部分时间都崩溃了

时间:2016-06-09 16:05:58

标签: ios swift amazon-web-services amazon-dynamodb

我正在尝试从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)")

运作良好。问题可能在另一个线程上,它错误地向我显示错误吗?如何最好地调试这个?谢谢

1 个答案:

答案 0 :(得分:0)

您正在尝试使用

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

已弃用。我建议你改用'keyConditionExpression'和'expressionAttributeValues'。

谢谢, 罗汉