兩個模型類NSPredicate比較兩個集和組和用戶共享一個多到多關係多到許多關係
AUser
- name
AGroup
- users
。
我希望檢查兩組是否有着完全相同的用戶(沒有更多的用戶或用戶更少)
但不幸的是我收到以下錯誤:一對多這裏不允許
關鍵請注意,我查看了其他SO問題,但沒有一個似乎適合,因爲我試圖在過去2個小時內使用它們的方法,但是我無法使其工作。或者至少我沒有很好地理解他們。
也是我的謂詞是否可以比較兩個可變集?
- (BOOL)conversationExists:(NSMutableSet *)members {
NSFetchRequest *request= [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"AGroup" inManagedObjectContext:_managedObjectContext];
NSPredicate *predicate =[NSPredicate predicateWithFormat:@"users==%@",members];
//There is more code that I have not shown here as it is irrelevant to the question
//Mainly The NSPredicate line is the problem
}
非常感謝你的時間。對此,我真的非常感激。
從, 新的iOS程序員
我只是覺得你需要將謂詞用於提取請求使用核心數據(或者至少我所看到的所有例子只使用了謂詞)。謝謝,順便說一下! – GangstaGraham 2013-03-07 21:03:58
如果你使用'NSFetchRequest',你可以做,但你不需要使用'NSFetchRequest'。 – 2013-03-08 02:29:16
這可能聽起來像一個愚蠢的問題。我只是好奇,在選中這個問題之前,是否檢查所有組? – GangstaGraham 2013-03-08 03:40:15