在境界中与任何人进行NSPredicate

时间:2015-04-17 18:25:06

标签: ios swift nspredicate realm

我在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
}

1 个答案:

答案 0 :(得分:0)

您的格式字符串中有一个错误的右括号。