简体   繁体   中英

NSPredicate ( nsdictionary+array+nsdictionary)

I have try to NSPredicate but all time get response 0. check blow code and provide your suggestion where going fault. soureceArray:- {

CityId = 0;
TreatmentProgramServices =     (
            {
        TreatmentServicesId = 9;
        TreatmentServicesName = Coed;
    },
            {
        TreatmentServicesId = 1;
        TreatmentServicesName = Intervention;
    },
            {
        TreatmentServicesId = 3;
        TreatmentServicesName = Residential;
    }
);
TreatmentProgrameId = 3;

}

filterTreatmentServices is array Count is :- {3}

 NSPredicate* updatePre =  [NSPredicate predicateWithFormat:@"(%K IN %@)",@"TreatmentProgramServices.TreatmentServicesId" ,filterTreatmentServices];

 filterTreatmentService =[soureceArray filteredArrayUsingPredicate:updatePre];

Please suggest solution

plz use this

  NSArray *filterArray=[soureceArray filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id  _Nonnull evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
                return [[evaluatedObject valueForKey:TreatmentServicesId]  == 3];
            }]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM