0

I have completely removed PSTCollectionView from my project, at one point, I'm getting following error, PSTCollectionViewItemTypeCell not found. I'm aware that, I need to replace it with something available in UICollectionView but I haven't found it on myself.

Is anyone experienced both (PSTCollectionView/UICollectionView) then please suggest me an alternative for that peace of code.

This is a rare question as from iOS 6.0 and above versions – people may upgrade to UICollectionViewsmoothly. However, I'm running an old project and that needs to be completely restructured for iOS 9.0.

Please help.

Here's the problematic code:

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewLayoutAttributes *attributes = (UICollectionViewLayoutAttributes *)[super layoutAttributesForItemAtIndexPath:indexPath];
    if ([attributes representedElementCategory] == PSTCollectionViewItemTypeCell) {
        //some good code.
    }
    return attributes;
}
Hemang
  • 26,840
  • 19
  • 119
  • 186

1 Answers1

0

You can see from the PSTCollectionView repository that PSTCollectionViewItemTypeCell is a member of the PSTCollectionViewItemType enum:

typedef NS_ENUM(NSUInteger, PSTCollectionViewItemType) {
    PSTCollectionViewItemTypeCell,
    PSTCollectionViewItemTypeSupplementaryView,
    PSTCollectionViewItemTypeDecorationView
};

This is essentially the equivalent of UICollectionElementCategory:

typedef enum {
   UICollectionElementCategoryCell,
   UICollectionElementCategorySupplementaryView,
   UICollectionElementCategoryDecorationView 
} UICollectionElementCategory;

It should be simply a case of replacing one for the other:

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewLayoutAttributes *attributes = (UICollectionViewLayoutAttributes *)[super layoutAttributesForItemAtIndexPath:indexPath];
    if ([attributes representedElementCategory] == UICollectionElementCategoryCell) {
        //some good code.
    }
    return attributes;
}
Steve Wilford
  • 8,894
  • 5
  • 42
  • 66