2017-11-07 28 views
0

나는 다음과 같은 한 응답은 2NSArray에서 다른 JSON objectForKey를 제거하는 방법은 무엇입니까? 필터 배열의

if(requestType == RequestTypeGetReportMaterialStatus) 
      { 
       materialStatusArray=response[@"customerstatus"]; 
       NSLog(@"Filtered Array2%@",materialStatusArray); 
} 

1 =  { 
    bookingid = 469; 
    status = 1; 
}; 
2 =  { 
    bookingid = 493; 
    status = 1; 
}; 
3 =  { 
    bookingid = 486; 
    status = 1; 
}; 
4 =  { 
    bookingid = 501; 
    status = 1; 
}; 
5 =  { 
    bookingid = 506; 
    status = 1; 
}; 

하지만이 배열에 저장에 대한 응답하려는되는

{ 

    bookingid = 469; 

    status = 1; 

}; 

    { 

    bookingid = 493; 

    status = 1; 

}; 

    { 

    bookingid = 486; 

    status = 1; 

}; 

    { 

    bookingid = 501; 

    status = 1; 

}; 

    { 

    bookingid = 506; 

    status = 1; 

}; 

어떻게 내가 얻을 수있는 번호를 잘라서 넣어 밖으로 다음을 제공합니다 위의 배열 응답 형식으로 비교 목적을위한 예약 값과 상태 값에 액세스합니다 ... 내 응답에 따라 코드 스 니펫을 제공하여 나를 도와주세요.

미리 감사드립니다.

답변

0

나는 materialStatusArray 실제로있는 NSDictionary 추측은, 배열처럼 변환 할 수 있습니다 :

NSMutableArray *arrayWithoutNumbers = [NSMutableArray array]; 

if ([materialStatusArray isKindOfClass:[NSDictionary class]]) { 
    NSDictionary *dict = (NSDictionary *)materialStatusArray; 
    [dict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { 
     [arrayWithoutNumbers addObject:obj]; 
    }] 
} 
+0

이 완벽한 솔루션입니다, 감사합니다! – Fido