我在NSPredicate
中使用Realm
时有例外:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Unable to parse the format string "ANY phones.number CONTAINS %@)"'
人员类:
class Person: RLMObject {
...
dynamic var phones = RLMArray(objectClassName: Phone.className())
}
电话课程:
class Phone: RLMObject {
dynamic var number = ""
dynamic var formattedNumber = ""
}
构建电话谓词:
func phonesPredicate(#searchString:String) -> NSPredicate {
let searchPredicate = NSPredicate(format: "ANY phones.number CONTAINS %@)", searchString)
return searchPredicate
}
答案 0 :(得分:0)
您的格式字符串中有一个错误的右括号。