ios - 带有字符串的 NSPredicate 似乎没有返回结果

标签 ios xcode core-data swift nspredicate

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/

相关文章:

multithreading - 有什么方法可以在不创建伪造的 NSThread 的情况下进入 Cocoa 多线程模式?

ios - 下载 ios 5 模拟器并将其添加到没有 xcode 组件的 xcode 4.5 和 monotouch

ios - 无法将“UINavigationController”类型的值转换为 tabBarController

iphone - 我应该如何迁移我的核心数据?

ios - Swift - 使用 for 循环将数据添加到核心数据

xcode - 在扩展/合并核心数据模型的同时保留数据

ios - Alamofire+组合 : how to get custom error type out of AFError

ios - 带休息套件的 POST

ios - 每个部分的动态行

ios - Xcode 5.0.1 在运行后崩溃