0

이 도메인의 항목 수를 반환하고 싶습니다. count (*)는 Count라는 속성을 가진 Domain이라는 항목 하나를 반환합니다. 백작의 가치를 얻으려면 어떻게해야합니까? SimpleDB iPhone에서 개수 선택 (*)

@try { 
    SimpleDBSelectRequest *selectRequest2 = [[SimpleDBSelectRequest alloc] initWithSelectExpression:@"select count(*) from %@"]; 
    SimpleDBSelectResponse *selectResponse = [[AmazonClientManager sdb] select:selectRequest2]; 

    for (SimpleDBItem *item in selectResponse.items) { 
    if ([item.name isEqualToString:@"Domain"]) 
    { 
     NSLog(@"Attributes = %@",[item.attributes objectAtIndex:0]); 
    } 
    } 
} 
@catch (AmazonServiceException *exception) { 
    NSLog(@"Exception = %@", exception); 
} 

나는이 속성 얻을 :

Attributes = {Name: Count,AlternateNameEncoding: (null),Value: 3,AlternateValueEncoding: (null),<SimpleDBAttribute: 0x8667120>} 

가 어떻게 그것의 값 3받을 수 있나요?

+0

대답의 코드가 작동하지 않습니다

그것은 뭔가 같은 것? 그것은 바로 뒤에 또는 NSLog (@ "Attributes ...") 문 대신 사용되어야합니다. – FluffulousChimp

+0

이 작업 방식 : (item.attributes의 SimpleDBAttribute * attr) { if ([attr.name isEqualToString : @ "Count"]) { int total = [attr.value intValue]; – Eric

답변

0

이 근무 :

for (SimpleDBAttribute *attr in item.attributes) { if ([attr.name isEqualToString:@"Count"]) { int total = [attr.value intValue]; 
1

selectResponse에는 items 속성이 있어야합니다.이 속성은 SimpleDBReplaceableAttribute 인스턴스의 가변 배열입니다. name 속성이 "Count"이고 value 속성이 개수를 나타내는 문자열이어야합니다.

SimpleDBReplaceableAttribute *attribute = [[selectResponse items] objectAtIndex:0]; 
    NSInteger count = [[attribute value] integerValue];