开发者

AND NSPedicate on Core Data relationships

开发者 https://www.devze.com 2022-12-31 07:30 出处:网络
I\'m having trouble compoun开发者_运维技巧ding NSPredicate with AND, although using OR works fine.

I'm having trouble compoun开发者_运维技巧ding NSPredicate with AND, although using OR works fine.

Imagine 2 entities, Doctor and Patient. Doctors can have many patients and patients many doctors. I want to find doctors that, say, have both person1 and person2 as patients. I expected this to work but it returns none.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY patients matches 'person1&&person2'"];

If I change && to ||, I get all doctors that have person1 or person2 as I'd expect.

Thanks in advance for your help.


It looks like a known issue that 2 ANY statements can't be compounded via AND. Back to the drawing board... link text

0

精彩评论

暂无评论...
验证码 换一张
取 消