func getFetchRequest(#entityName: String, address value: String) -> NSFetchRequest {
var fetch = NSFetchRequest(entityName: entityName)
fetch.predicate = NSPredicate(format: "address = %s", value)
println(fetch)
return fetch
}
问题是它与 Xcode <6.1 一起工作并停止与 6.1 一起工作。
传递 getFetchRequest(entityName: "Entity", address: "test")
给出以下内容
(
entity: Entity;
predicate: (address == "s");
sortDescriptors: ((null));
type: NSManagedObjectResultType;
)
最佳答案
Solution found in another answer可能会算这个重复项。
解决方案
NSPredicate(format: "address = %s", value)
应该是:
NSPredicate(format: "address = %@", value)
关于ios - 带有字符串的 NSPredicate 似乎没有返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26616046/