【发布时间】:2015-02-19 03:41:27
【问题描述】:
我在使用 Dynamo AWS 时遇到问题,我试图从数据库中获取 ID 并随机获取内存分配错误。 以下是我用来获取信息的代码:
AWSCognitoCredentialsProvider *credentialsProvider = [AWSCognitoCredentialsProvider credentialsWithRegionType:AWSRegionUSEast1
accountId:AWSAccountID
identityPoolId:CognitoPoolID
unauthRoleArn:CognitoRoleUnauth
authRoleArn:CognitoRoleAuth];
//Set the server connection to AWSRegionUSEast1 with the credentials
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1
credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;
NSString *token = FBSession.activeSession.accessTokenData.accessToken;
credentialsProvider.logins = @{ @(AWSCognitoLoginProviderKeyFacebook): token };
//Access the users table with the Facebook ID.
DDBTableRow *tableRow = [DDBTableRow new];
tableRow.UsersHash1ID = [defaults objectForKey:@"UserID"];
tableRow.UsersRange1 = [defaults objectForKey:@"UserID"];
AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
//Create a load connection to the AWS Dynamo database to find out if the user already exists
[[dynamoDBObjectMapper load:[DDBTableRow class]
hashKey:tableRow.UsersHash1ID
rangeKey:tableRow.UsersRange1] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task) {
if (!task.error) {
DDBTableRow *tableRow = task.result;
//TODO: Crashes
if (tableRow.UsersHash1ID == nil) {// if the user does not exist.
[self firstPlay];
} else {
[self SecondPlay]; //If the user exist already in the database.
}
} else { //Error handling
NSLog(@"Error: [%@]", task.error);
//TODO: handle the connection
HUD.textLabel.text = @"Error Connecting to Database";
[HUD dismissAfterDelay:5.0];
}
return nil;
}];
这是我收到的错误: Image Error
有人知道怎么解决吗?
【问题讨论】:
标签: ios amazon-web-services amazon-dynamodb