Preventing subclassing in Objective-C
January 9, 2016
For those of you still using Objective-C, I found a cool attribute that allows you to basically define
The attribute is
For example:
The compiler now will prevent any subclassing of
final
classes. The attribute is
__attribute__((objc_subclassing_restricted))
For example:
__attribute__((objc_subclassing_restricted))
@interface MyClass : NSObject
The compiler now will prevent any subclassing of
MyClass
!