M.K.
M.K.

Reputation: 29

UICollectionView XCode Custom cell

I created a custom class for super UICollectionViewCell. Now when I call

MyCollectionViewCell *itemView = [self.collectionView cellForItemAtIndexPath:indexPath];

I get a warning:

"Pointers types do not match",(cellForItemAtIndexPath:indexPath] returns UICollectionView cell ).

How do I fix it?

Upvotes: 1

Views: 244

Answers (1)

jacob bullock
jacob bullock

Reputation: 651

The warning is because cellForItemAtIndexPath returns a UICollecitonViewCell. you have to cast it as a MyCollectionViewCell such as:

MyCollectionViewCell *itemView = (MyCollectionViewCell*)[self.collectionView cellForItemAtIndexPath:indexPath];

This should take care of the warning.

Upvotes: 4

Related Questions