第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

我有兩個(gè)類,ClassA和ClassB,關(guān)系如下:

我有兩個(gè)類,ClassA和ClassB,關(guān)系如下:

iOS
千萬里不及你 2023-04-15 22:18:31
我需要查詢所有count>10的ClassA的bObjects中name為hello的ClassB的對象。請問能不能用一個(gè)NSPredicate來表示這個(gè)查詢?
查看完整描述

2 回答

?
精慕HU

TA貢獻(xiàn)1845條經(jīng)驗(yàn) 獲得超8個(gè)贊

看了蘋果的文檔,里面寫的例子:

If you use a to-many relationship, the construction of a predicate is slightly different. If you want to fetch Departments in which at least one of the employees has the first name "Matthew," for instance, you use an ANY operator as shown in the following example:
 NSPredicate *predicate = [NSPredicate predicateWithFormat:    @"ANY employees.firstName like 'Matthew'"];

所以,我覺得查詢應(yīng)該是:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(name = %@) AND (ANY aObjects.count > 10)", @"hello"];


查看完整回答
反對 回復(fù) 2023-04-19
?
阿波羅的戰(zhàn)車

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊

腦補(bǔ)的,沒測試。不好用請更正我

NSEntityDescription *entity = [NSEntityDescription
                                   entityForName:@"ClassB"
                                   inManagedObjectContext:context];NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(name = %@) AND (aObjects.count > 10)", @"hello"];
[fetchRequest setPredicate:predicate];


查看完整回答
反對 回復(fù) 2023-04-19
  • 2 回答
  • 0 關(guān)注
  • 153 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號