[英]AWS iOS SDK simpleDB item count
i just started out working on a project using Amazon Web Services SimpleDB. 我刚刚开始使用Amazon Web Services SimpleDB开展项目。 in one method i am trying to figure out how many items a domain already contains by using a
select query
. 在一种方法中,我试图通过使用
select query
来确定域已经包含了多少项。
The code looks like this: 代码如下所示:
AmazonSimpleDBClient *dbClienet = [[AmazonSimpleDBClient alloc]initWithAccessKey:_secret withSecretKey:_hiddenSecret];
NSString *countRequestString = [NSString stringWithFormat:@"select count(*) from %@",domain];
SimpleDBSelectRequest *countRequest = [[SimpleDBSelectRequest alloc]initWithSelectExpression:countRequestString];
SimpleDBSelectResponse *countResponse = [dbClienet select:countRequest];
This works just fine. 这很好用。 eg: the connection works, and the response seems to be right as well when i log it:
例如:连接工作,当我记录它时,响应似乎也是正确的:
{Items: (
"{Name: Domain,AlternateNameEncoding: (null),Attributes: (\n \
"{Name: Count,AlternateNameEncoding: (null),Value: 2,AlternateValueEncoding: (null),<SimpleDBAttribute: 0x756f730>}\"\n),<SimpleDBItem: 0x7529d00>}"),NextToken: (null),{BoxUsage: 0.000023,{requestId: b683ed01-9e5f-9041-1ace-cbb0fdfaa799}}}
What i want to do next, is to save the value 2
into an NSInteger itemCount
. 我接下来要做的是将值
2
保存到NSInteger itemCount
。 Here is where i struggle. 这是我挣扎的地方。 I tried several things, the furthest i came was:
我尝试了几件事,我来的最远的是:
NSInteger itemCount = [[[[[countResponse.items objectAtIndex:0]attributes]objectAtIndex:1]value]integerValue];
which should work in my eyes. 哪个应该在我眼里工作。 but it throws the error:
但它会抛出错误:
Multiple methods named 'value' found with mismatched result, parameter type or attributes
Can anyone point out to me where i went wrong? 任何人都可以向我指出我哪里出错了吗? I am truly stuck here.
我真的被困在这里了。
Thanks, Sebastian 谢谢,塞巴斯蒂安
Thanks to the comment of geraldWilliam i figured it out: 感谢geraldWilliam的评论我发现了:
NSString *countRequestString = [NSString stringWithFormat:@"select count(*) from %@",domain];
SimpleDBSelectRequest *countRequest = [[SimpleDBSelectRequest alloc]initWithSelectExpression:countRequestString];
SimpleDBSelectResponse *countResponse = [dbClienet select:countRequest];
NSArray* attributes = [[countResponse.items objectAtIndex:0]attributes];
for (SimpleDBAttribute*attr in attributes) {
if ([attr.name isEqualToString:@"Count"]) {
itemCount = [attr.value integerValue];
}
}
This approach works. 这种方法有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.