2017-07-07 51 views
1

是否有人可以幫助我構建一個領域查詢來搜索特定的entryid值的視頻,以獲得額外的第二個查詢,這些查詢可以通過它們的entryids查找這兩個視頻?針對Realm對象的NSPredicate查詢

謝謝!

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]; 

且其變動無濟於事。

回答

0

NSPredicate使用關鍵路徑遍歷屬性(object.someProperty.otherProperty)。

根據您的示例數據,您需要一個謂詞,如video_kalutra.entryid == '0_abababa3'

+0

謝謝!那工作。我已經擴展它與數組一起工作。 NSPredicate * pred = [NSPredicate predicateWithFormat:@「video_kaltura.entryid IN%@」,entryids]; – TrekOnTV2017