가 여기JSON 모델 - 방법 "arrayOfModelsFromDictionaries"
@interface ProductModel : JSONModel
@property (assign, nonatomic) int id;
@property (strong, nonatomic) NSString* name;
@property (assign, nonatomic) float price;
@property (assign, nonatomic) BOOL isOK;
@end
다음 다음과 같이 내가 JSONModel을 만든
[{
"id": 1,
"name":"Soup",
"price":200,
"isOK":1
},
{
"id": 2,
"name":"Salad",
"price":100,
"isOK":0
}]
내 JSON 데이터를 사용하는 경우 배열에 모든 객체를 추가하지
NSArray* modelsArray = [ProductModel arrayOfModelsFromDictionaries:objects];
이제 내가 원하는 것은
if(isOK)
{
// then add the model into the modelsArray
} else {
// then don't add the model into the modelsArray
}
modelsArray를 반복 한 다음 isOK를 기준으로 객체를 하나씩 제거하지 않고도이 논리를 모델 파일 내 어딘가에 작성할 수 있습니까?
isok 값의 모델링 영역에서 개체를 제거 하시겠습니까? –
@balkaran singh thats corrects, 그러나 배열을 다시 반복하지 않고 – Haider
이것을 위해 NSPredicate를 사용할 수 있습니다. –