NSManagedObject relation nsset iteration

I have a subclass NSManagedObject(ObjectA) that is related to one another in another subclass NSManagedObject(ObjectB). I get an ObjectB NSSetfrom an ObjectA generated method.

I want to determine if an ObjectB with the given "name" exists in the returned one NSSet(for example, ObjectB.name == "xxx").

What is the most efficient way to determine if the NSSetobject contains it rather than iterating / comparing my path through the whole NSSet?

Greetings

+3
source share
1 answer

To get a set with all objects matching the condition:

[aSet filterSetUsingPredicate [NSPredicate predicateWithFormat: @ ", % @", aString]]

, .

[[aSet filterSetUsingPredicate [NSPredicate predicateWithFormat: @ "name like% @", aString]] count]

0

Source: https://habr.com/ru/post/1719179/


All Articles