You are declaring the cell as a UICollectionViewCell
, which does not have an x property
. You are also casting the instance of the cell to your custom class, but the cell variable is still declared as a UICollectionViewCell
. Instead, you could create a super class for TaskCollectionCell
and PeopleCollectionCell
, which declares the x property
.
E.g.
NSString * const PeopleCollectionCellIdentifier = @"PeopleCollectionCell";
NSString * const TaskCollectionCellIdentifier = @"TaskCollectionCell";
CustomSuperClass * cell = (self.arePeopleNotTasks) ? [cv dequeueReusableCellWithReuseIdentifier:PeopleCollectionCellIdentifier forIndexPath:indexPath] : [cv dequeueReusableCellWithReuseIdentifier:TaskCollectionCellIdentifier forIndexPath:indexPath];
cell.x = @"this is an awesome string";
if ([cell.reuseIdentifier isEqualToString:PeopleCollectionCellIdentifier])
{
PeopleCollectionCell * peopleCollectionCell = (PeopleCollectionCell *)cell;
peopleCollectionCell.peopleOnlyProperty = nil;
}
else if ([cell.reuseIdentifier isEqualToString:TaskCollectionCellIdentifier])
{
TaskCollectionCell * taskCollectionCell = (TaskCollectionCell *)cell;
taskCollectionCell.taskOnlyProperty = nil;
}
return cell;