Reputation: 251
I am trying to query realm for an object with a filter condition and it keeps failing for strings with new line characters
results = realm.objects(LocalizedString).filter(filterString!)
Here filterString contains the string
"tuvEnglish = 'Ndjdj\n' AND tuvThai = 'Ndjdj\n'"
This fails with the error
'NSInvalidArgumentException', reason: 'Unable to parse the format string "tuvEnglish = 'Ndjdj
' AND tuvThai = 'Ndjdj
'"'
How should I fix this? Please help.
Upvotes: 1
Views: 244
Reputation: 7806
You will need to pass the strings as dedicated arguments and not built-in to the format string like that:
results = realm.objects(LocalizedString).filter("tuvEnglish = %@ AND tuvThai = %@", "Ndjdj\n", "Ndjdj\n")
Upvotes: 2