0
화합물 NSPredicate를 사용하는 방법을 알고 싶습니다.화합물 NSPredicate 사용 방법
필자는 다음과 같이 시도했지만, currentInstall 배열은 술어가 적용된 이후와 정확히 동일합니다.
NSArray *currentInstall = [coreDataController filterReadInstalls:selectedInstallID];
NSArray *tempArray = [currentInstalls filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"cHR == 0"]];
currentInstalls = [tempArray copy];
NSPredicate *predicateAreaString = [NSPredicate predicateWithFormat:@"area == %@", [myFilter objectForKey:@"area"]];
NSPredicate *predicateBString = [NSPredicate predicateWithFormat:@"stage == %@", [myFilter objectForKey:@"area2"]];
NSPredicate *predicateCString = [NSPredicate predicateWithFormat:@"partCode == %@", [myFilter objectForKey:@"area3"]];
NSPredicate *predicateDString = [NSPredicate predicateWithFormat:@"doorNo CONTAINS[cd] %@", [myFilter objectForKey:@"door"]];
NSPredicate *predicateEString = [NSPredicate predicateWithFormat:@"doorDesc CONTAINS[cd] %@", [myFilter objectForKey:@"doorDesc"]];
NSPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:@[predicateAreaString, predicateBString, predicateCString, predicateDString, predicateEString]];
NSMutableArray *filteredArray = [NSMutableArray arrayWithArray:[currentInstalls filteredArrayUsingPredicate:compoundPredicate]];
currentInstalls = [filteredArray mutableCopy];
어떤 도움을 주시면 감사하겠습니다.
괜찮아요. 나는 두 곳으로 전화를 걸어 그곳에서 일하며 그것이 어떻게되는지 보게 될 것입니다. 복합물 술어를 사용했을 때 처음 이었기 때문에 abit는 atm을 잃었습니다.하지만 계속 노력할 것입니다. – HurkNburkS
좋아요, 그래서 하나의 술어를 사용하여 배열을 필터링 해 보았습니다. 복합 술어가 작동하지 않는 이유는 확실하지 않습니다. – HurkNburkS
작동하지만 ... orPredicateWithSubpredicates를 사용하고 있기 때문에 모든 것을 반환합니다. andPredicateWithSubpredicates로 변경했으며 이제 올바른 정보를 반환합니다. – HurkNburkS