我正在尝试查询带有筛选条件的对象的领域,对于带有新行字符的字符串,它一直失败
results = realm.objects(LocalizedString).filter(filterString!)
这里filterString包含字符串
"tuvEnglish = 'Ndjdj\n' AND tuvThai = 'Ndjdj\n'"
失败的原因是错误
'NSInvalidArgumentException', reason: 'Unable to parse the format string "tuvEnglish = 'Ndjdj
' AND tuvThai = 'Ndjdj
'"'
我该怎么解决?请帮忙。
最佳答案
您需要将字符串作为专用参数传递,而不是内置到格式字符串中,如下所示:
results = realm.objects(LocalizedString).filter("tuvEnglish = %@ AND tuvThai = %@", "Ndjdj\n", "Ndjdj\n")