Reputation: 14060
Swift 3, Realm 2.1
I'm trying to figure out how to search my Aircraft
objects based on values in its related fieldValues
list. Here is a simplified view of my class structure:
class Aircraft: Object {
dynamic var makeModel = ""
let fieldValues = List<FieldValue>()
}
class FieldValue: Object{
dynamic var name = ""
}
I can search the makeModel
value (where search!
is my search term) like this:
let makeModelPredicate = NSPredicate(format: "makeModel BEGINSWITH[c] %@", search!)
...but how do I check to see if search
matches any name
values in the fieldValues
list?
Upvotes: 0
Views: 261
Reputation: 8138
You can query over key paths: NSPredicate(format: "ANY fieldValues.name = %@", search!)
Upvotes: 2