__NSmallocblock__ 亚马逊 AWS Dynamo 错误 - iOS

__NSmallocblock__ Amazon AWS Dynamo Error - iOS

我在使用 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

有人知道怎么解决吗?

- load:hashKey:rangeKey: 是一种异步方法。这意味着您创建的第一个 tableRow 对象可以在 - load:hashKey:rangeKey: 完成执行之前被释放。

您可以重写此部分

[dynamoDBObjectMapper load:[DDBTableRow class]
                   hashKey:tableRow.UsersHash1ID
                  rangeKey:tableRow.UsersRange1]

类似

[dynamoDBObjectMapper load:[DDBTableRow class]
                   hashKey:[defaults objectForKey:@"UserID"]
                  rangeKey:[defaults objectForKey:@"UserID"]]

(您为哈希键和范围键设置了相同的值。您应该确保这是您真正想要的。)

如果不能解决问题,您应该启用 NSZombie 并查看释放了哪些对象。