【问题标题】:how to set NSPredicate in CoreData fetch如何在 CoreData fetch 中设置 NSPredicate
【发布时间】:2013-01-17 11:35:55
【问题描述】:

我的 coreData 中有一个包含一些值的实体。 cTitle(字符串)和价格(浮动)

例如: cTitle(牛奶、面包、啤酒) 价格 (30, 20, 15);

我需要获取价格为

我正在尝试设置谓词

NSNumber *pr = [NSNumber numberWithFloat: 20.0];
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"cPrice > %@)", pr];
[fetchRequest setPredicate:predicate];

但它会因错误而崩溃 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "cPrice > %@)"'

它是单一实体,没有关系。

怎么了?看不懂。

【问题讨论】:

    标签: ios core-data nspredicate


    【解决方案1】:

    删除%@)"附近的)

    NSPredicate *predicate = [NSPredicate predicateWithFormat: @"cPrice < %@", pr];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 2012-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      相关资源
      最近更新 更多