有两个实体(Department <-->> Employee)。
这个部门有4名员工。当我获取该部门的所有员工时,我的日志窗口显示:
CoreData:注释:总提取执行时间:0.0017 秒,4 行。
一切都很好。
但UICollectionView
仅显示第一个员工 4 次。例如:
雇员 1、雇员 1、雇员 1、雇员 1
代替
员工 1、员工 2、员工 3、员工 4
我觉得cellForItemAtIndexPath有一些错误:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cellRecipe";
collectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
Employee *emp = [array_ objectAtIndex:indexPath.item];
cell.name.text = emp.name;
cell.image.image = emp.thumbImg;
return cell;
}
array_是获取后的NSMutableArray