2015-01-09 2 views
1

나는 이와 같은 dict formate를 가지고있다. 사전의 dict 키 안에 "quantity1"키를 사용하여 배열을 정렬해야합니다. ios에서 사전의 배열을 정렬하는 방법

array: (
{ 
    brand = Ryul; 
    productTitle = Any; 
    quantity = 1; 
    subBrand = "Ryul INJ"; 
    type = Product; 
    dict = { 
     brand1 = Trol; 
     productTitle1 = Different; 
     quantity1 = 2; 
     subBrand1 = ""; 
     type1 = Brand; 
     }; 
}, 
{ 
    brand = Trol; 
    productTitle = Different; 
    quantity = 2; 
    subBrand = ""; 
    type = Brand; 
    dict = { 
     brand1 = Trol; 
     productTitle1 = Different; 
     quantity1 = 2; 
     subBrand1 = ""; 
     type1 = Brand; 
     }; 
} 
) 

나는 정렬이 코드를 사용 : 내가 키 "수량"을 사용하는 경우가 작동

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"quantity" ascending:YES]; 
    stories=[stories sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]; 
    recent = [stories copy]; 

. 하지만 "quantity1"키를 사용할 때 작동하지 않습니다.

어떻게 분류할까요?

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"dict.quantity1" ascending:YES]; 
stories=[stories sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]; 

키가 DICT이다 사용하여 저

답변

11

도움이됩니다. 수량 1

+0

감사합니다.이 문제가 없습니다. –

+0

@HariBabu 당신이 문제를 해결할 수 있도록 Suen에게 신용해야합니다. – soulshined

관련 문제