我有两个表Photo
和Photographer
。 下面是表格的结构。客观c - 取数据(核心数据)
我想取谁采取了一个名为“熊猫”的照片全部Photographers
的名称。
这是我的代码,但由于某种原因它返回空。
NSArray *matchingPhotographers;
NSFetchRequest *fetch = [[NSFetchRequest alloc]init];
NSEntityDescription *desc = [NSEntityDescription entityForName:@"Photographer" inManagedObjectContext:context];
[fetch setEntity:desc];
[fetch setPredicate:[NSPredicate predicateWithFormat:@"photo.name like[c] %@",@"Panda"]];
NSError *error;
matchingPhotographers = [context executeFetchRequest:fetch error:&error];
NSLog(@"Photographers: %@", matchingPhotographers);
我做错了什么?该查询肯定会返回至少1名摄影师。
感谢
第一眼看不出有什么问题。你确定它是熊猫/熊猫? – 2015-03-13 07:51:20