所以我想解決如何使用這些謂詞,我已經閱讀了Apple文檔並試圖使用它(https://developer.apple.com/library/ mac /#documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html),並且我已經設置了謂詞,但它不斷得到線程1:EXC_BAD_ACCESS(code =)等等。核心數據謂詞與鍵路徑
NSError *error;
NSLog(@"1");
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Fruit" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSLog(@"2");
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"Source.sourceName contains[cd] %@", "Apple Tree"];
[fetchRequest setPredicate:predicate];
NSLog(@"3");
NSArray *fetchResult = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
NSLog(@"4");
testLbl.text = [fetchResult objectAtIndex:0];
,這是我正在使用的代碼,作爲核心數據,我們有......
實體水果&來源
屬性fruitName & SOURCENAME
關係(一對一)fruitSource < ---------> sourceFruit
我想要什麼要做的是拔出來自蘋果樹的任何水果...>。 <
謝謝!血腥的@符號,它總是一些不是嗎?!感謝您的建議:D – Craig