Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

EXC_BAD_INSTRUTION Error #7

Closed
etamity opened this Issue · 1 comment

2 participants

@etamity

Hi,
I was trying to use AWSiOSSDKV2 with Swift and got stuck.
Basically i want to put an item to DynamoDB, and I am sure the table and hashkey already created. But when I run this code always getting EXC_BAD_INSTRUTION Error on println("\(putItemOutput.description)") and return nil.

Any one have any ideas? please help, thank you.

@IBAction func insertAction(sender: AnyObject) {
    let dynamoDB=AWSDynamoDB.defaultDynamoDB()
    let myKey="UserId"
    let myValue="RecordId"

    let putItemInput:AWSDynamoDBPutItemInput=AWSDynamoDBPutItemInput()
    putItemInput.tableName = "UserData";
    let hashValue:AWSDynamoDBAttributeValue = AWSDynamoDBAttributeValue()
    hashValue.S = myKey
    let otherValue:AWSDynamoDBAttributeValue = AWSDynamoDBAttributeValue()
    otherValue.S = myValue
    putItemInput.item = [
        "UserId" : hashValue,
        "RecordId" : otherValue
    ]
    // putItemInput.returnValues = AWSDynamoDBReturnValueAllOld

    dynamoDB.putItem(putItemInput).continueWithBlock {
        (task: BFTask!) -> AnyObject! in
        let putItemOutput = task.result() as AWSDynamoDBPutItemOutput
        println("\(putItemOutput.description)")

        return nil
    }
}
@etamity

i found out its about the Swift language problem, it should be like this.

dynamoDB.putItem(putItemInput).continueWithBlock{
    (task: BFTask!) -> BFTask in if task.isCancelled() {
        // the save was cancelled.
        println("isCancelled");
    } else if task.error() {
           println("\(task.error().description)");
        // the save failed.
    } else {
        // the object was saved successfully.
        let listTablesOutput = task.result() as AWSDynamoDBPutItemOutput
        println("good");
    }
   return task
}
@etamity etamity closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.