marciokoko
marciokoko

Reputation: 4986

UICollectionView app crashes with UICollectionViewCell not key value compliant

I started creating a project with UICollectionView. I dragged a UICollectionViewController to storyboard and made properly identified it in the inspector. Then I dragged in a UITableViewCell and a UILabel into it. I created MyCell with a UILabel property and connected it to the outlet. The cell is properly identified in the inspector as well.

But when I run the app it crashed with the:

[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key cellLabel

where cellLabel is the UILabel property of MyCell. Here is my cellForItemAtIndexPath:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
    cell.cellLabel.text = [[object valueForKey:@"timeStamp"] description];
    return cell;
}

And Cell is the identifier in the Attributes Inspector.

What could be wrong?

Upvotes: 0

Views: 1733

Answers (2)

marciokoko
marciokoko

Reputation: 4986

It was an XCode5 error. It didnt associate the target membership for the MyCell.m class file for some reason.

Upvotes: 0

Karl
Karl

Reputation: 1233

Check in Interface-Builder if you set the CustomClass property for you custom Cell to MyClass.

Upvotes: 1

Related Questions