在以下代码中:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
UILabel *label = (UILabel *)[cell viewWithTag:1];
Person *person = [self.fetchedResultsController objectAtIndexPath:indexPath];
label.text = person.fullName;
UIImageView *iv = (UIImageView *)[cell viewWithTag:2];
NSPredicate *pr = [NSPredicate predicateWithFormat:@"person == %@", person];
Image *image = [Image MR_findFirstWithPredicate:pr inContext:person.managedObjectContext];
iv.image = image.image ? image.image : [UIImage imageNamed:@"placeholder"];
return cell;
}
这条线
Image *image = [Image MR_findFirstWithPredicate:pr inContext:person.managedObjectContext];
正在使用非法上下文。我尝试使用本地上下文而不是person.managedObjectContext
,但它仍然是非法的。
有什么想法吗?