Is it possible to hide @property in a subclass?

My application subclasses are UICollectionViewFlowLayout and uses all its properties except minimumLineSpacing . To avoid confusion, I would like to be able to “hide” minimumLineSpacing from the outside, so it looks like my subclass doesn't even support it. Is it possible?

+4
source share
2 answers

Yes, you can. View. You can mark it with __attribute__((unavailable)) , which will cause the compiler to throw an error if you use it. However, the property will still be available if your object is ported to its superclass type, since this is a compilation of only time.

 @interface MyClass : UICollectionViewFlowLayout @property (nonatomic) CGFloat minimumLineSpacing __attribute__((unavailable)); @end 
+12
source

I do not think you can hide it. You could, of course, rewrite the getter and setter and prevent a change in the current value, if that matters. But they will always exist and be visible.

+1
source

All Articles