0

使用 DynamoDBItemRequest 提取“firstName”对象,我得到的是:

{S: Will,N: (null),B: (null),SS: ( ),NS: ( ),BS: ( ),}

我尝试提取第一个对象,但它一直给我一个错误。经过一番挖掘,我意识到 DynamoDB 不返回 NSString 或 NSArray 对象。任何人有任何运气提取数据集?这是我的代码 -

-(void)tap
{  

DynamoDBGetItemRequest *getItemRequest = [[DynamoDBGetItemRequest new] autorelease];

DynamoDBAttributeValue *attributeValue = [[[DynamoDBAttributeValue alloc] initWithN:[NSString stringWithFormat:@"%d", 1]] autorelease];

getItemRequest.tableName = TEST_TABLE_NAME;
getItemRequest.key = [NSMutableDictionary dictionaryWithObject:attributeValue forKey:TEST_TABLE_HASH_KEY];

DynamoDBGetItemResponse *getItemResponse = [[AmazonClientManager ddb] getItem:getItemRequest];

NSMutableDictionary *userPreferences = getItemResponse.item;


NSArray *abc = [userPreferences objectForKey:@"lastName"];


NSLog(@"%@", abc);



}

这是我对不断给我错误的代码的尝试->

//    NSString *abb = abc[1];
//    NSLog(@"%@", abb);
4

1 回答 1

0

在 DynamoDB 中,属性只能是一种类型(String、Number、Binary、StringSet、NumberSet、BinarySet)。您要打印的对象是“String”类型,内容为“Will”。如果像这样打印,Dynamo 可能会更清晰:

{S:Will}

但它只是将 AttributeValue 转换为字符串,并向您显示其中的所有其他(空)值:

{S: Will,N: (null),B: (null),SS: ( ),NS: ( ),BS: ( ),}

其他一切都只是噪音;重要的是它是一个内容为“Will”的字符串。

于 2013-07-25T04:55:58.010 回答