waylonion
waylonion

Reputation: 6976

NSPredicate Search Through NSSet

Suppose you have the following Core Data model:

An Entity named Event.

An Entity named Tag.

The relationship between Event and Tag is many to many. So a single Event will have multiple Tags and a Tag will point to many Events.

My problem:

How do you create an NSPredicate that will return an array full of Events that contain a specific tag?

I want to populate a UITableView with Events that have the Tag that the user will specify.

Upvotes: 0

Views: 779

Answers (1)

Martin R
Martin R

Reputation: 539685

To fetch all objects that are related to the given tag, use

[NSPredicate predicateWithFormat:@"ANY tags == %@", givenTag];

Upvotes: 4

Related Questions