Modify (or add) property attributes of parent class

67 Views Asked by At

I'm working on building a UICollectionView subclass to cover up more convenient layouts in a simple way. It needs to have another delegate property to handle messages from custom UICollectionViewLayout class, which the UICollectionView class already has, so I wish the delegate property of UICollectionView handles both UICollectionViewDelegate and another custom delegate protocol.

More specifically, I'd like to build something like the followings.

@interface CPGridCollectionView : UICollectionView <CPGridLayoutDelegate>

// add protocol declaration to existing delegate property
@property (nonatomic, weak, nullable) id<UICollectionViewDelegate, CPGridLayoutDelegate> delegate;

// more additional features

@end

But warning came up as:

Auto property synthesis will not synthesize property 'delegate'; it will be implemented by its superclass, use @dynamic to acknowledge intention

It seems that I need to add attributes to existing property of UICollectionView, without breaking the functionality of UICollectionViewDelegate. Is this possible in Obj-C, and how can this warning be avoided?

0

There are 0 best solutions below