【问题标题】:iPhone NSPredicate how to create a predicate that checks if property has a value?iPhone NSPredicate 如何创建一个检查属性是否有值的谓词?
【发布时间】:2012-11-07 07:21:08
【问题描述】:

这可能是一个愚蠢的问题,但直到现在我所有的 NSPredicate 都给了他们某种密钥:

@"SELF.typeRelationship.categoryType != %d";

现在我需要创建一个谓词,该谓词将从核心数据中提取所有具有分配值的对象。任何价值都可以。

我的谓词看起来像:

@"SELF.typeRelationship.categoryType != 0";
@"SELF.typeRelationship.categoryType != nil";//if an object property?

,或者我应该使用什么更好的格式来检查一个属性是否有分配给它的对象?

【问题讨论】:

    标签: iphone ios core-data nspredicate


    【解决方案1】:

    如果categoryType 是字符串,则执行此操作,

    NSPredicate *predicateName = [NSPredicate predicateWithFormat:@"SELF.typeRelationship.categoryType.length > 0"];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-27
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      • 2016-09-17
      相关资源
      最近更新 更多