1
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。带字符串的NSPredicate看起来不会返回结果
传递getFetchRequest(entityName: "Entity", address: "test")
提供了以下
(
entity: Entity;
predicate: (address == "s");
sortDescriptors: ((null));
type: NSManagedObjectResultType;
)
你能'调用println(谓语)'的输出添加到各种工作和非工作情况下? – 2014-10-28 19:15:27
现在编写测试来确认,但它的值为“零”而不是“(...)”。这是不正确的,考虑到逐步执行,传递给NSPredicate的变量中有值。编辑:测试完成后将编辑。 – 2014-10-28 20:01:50
@MartinR这很奇怪。如果我直接进行单元测试,它就可以工作。代码不像我在问题中那样结构化,我需要更新以反映开发中的实际问题。单步执行代码具有价值,但是println(谓词)的值为“nil”。我完全不明白。 – 2014-10-29 18:38:32