开发者

NSPredicate acting strange in NSFetchedResultsController

开发者 https://www.devze.com 2022-12-25 23:07 出处:网络
I feel as if this should be very simple, but it\'s behaving strangely. I have 3 entities, with a relationship as such

I feel as if this should be very simple, but it's behaving strangely.

I have 3 entities, with a relationship as such

Entity A <-->> Entity B <<--> Entity C

I have an NSFetchedResults controller and I'm trying to filter the results of Entity A using the following predicate.

[NSPredicate predicateWithFormat:@"NONE entityB.entityC == %@", self.entityC];

When I try and run the app, the output shows no results. I can alter the predicate slightly to:

[NSPredicate predicateWithFormat:@"ANY entityB.entityC 开发者_运维问答== %@", self.entityC];

And it shows me only the results that I want it to filter out.

Why is this happening?


I think you may want a SUBQUERY expression:

@"SUBQUERY(entityB, $x, $x.entityC == %@).@count == 0"

though, it may work to do:

@"NOT (ANY entityB.entityC == %@)"

(note: I haven't tested the second option)

0

精彩评论

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

关注公众号