mercredi 2 septembre 2015

Synchronous connecting to AWS DynamoDB in Objective-c

How can I implement synchronous access to AWS DynamoDB in Objective-c?

I understood asynchronous access to DynamoDB using Bolts BFTask as below but I need "synchronous" connecting.

- (NSString *) ddbIDQuery: (NSString*)ddbid
{
    __block NSString *strpid = nil;

    AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
    [[dynamoDBObjectMapper load:[PIDTable class] hashKey:ddbid rangeKey:nil] continueWithBlock:^id(AWSTask *task)
     {
         NSLog(@"GNID: %@", ddbid);
         if (task.error){
             NSLog(@"The 1st request failed. Error: [%@]", task.error);
         }
         if (task.exception) {
             NSLog(@"The 1st request failed. Exception: [%@]", task.exception);
         }
         if (task.result) {
             PIDTable *ddbpid = task.result;
             NSData *datapid = [ddbpid.text dataUsingEncoding:NSUTF8StringEncoding];
             strpid = [[NSString alloc] initWithData:datapid encoding:NSUTF8StringEncoding];
         };
         return nil;
     }
     ];
     return strpid;
}




Aucun commentaire:

Enregistrer un commentaire