NSPredicate查询Realm对象

时间:2017-07-07 16:21:02

标签: objective-c realm nspredicate

有人可以帮我构建一个领域查询来搜索特定entryid值的视频,对于第二个查询可以通过其entryid查找两个视频的额外点吗?

谢谢!

Video {
    nid = 1;
    video_title = OK;
    video_description = Description {
        value = Description;
    };

    video_kaltura = Kaltura {
        entryid = 0_abababa3;
        mediatype = 1;
    };
}

Video {
    nid = 2;
    video_title = OK;
    video_description = Description {
        value = Description;
    };
    video_kaltura = Kaltura {
        entryid = 0_cdcdcdc3;
        mediatype = 1;
    };
}

我尝试过这样的事情:

NSPredicate *pred = [NSPredicate predicateWithFormat:@"video_kaltura['entryid'] CONTAINS[c] '0_abababa3'"];
RLMResults *test = [Video objectsWithPredicate:pred];

及其变化无济于事。

1 个答案:

答案 0 :(得分:0)

NSPredicate使用关键路径遍历属性(object.someProperty.otherProperty)。

根据您的示例数据,您需要一个谓词video_kalutra.entryid == '0_abababa3'