How to use the @dynamic directive in category implementation?

When I try to use the @dynamic directive in the implementation of a category, I get: "@dynamic may not be specified in a category without an interface."

Does anyone know if there is a way to use this directive in a category?

+3
source share
1 answer

Define the interface for the category, as well as for the class:

@interface NSObject (RetainProperty)
@property (nonatomic, readonly) BOOL moreThanOneRetain;
@end

@implementation NSObject (RetainProperty)
@dynamic moreThanOneRetain;

-(BOOL)moreThanOneRetain
{
    return (1 < [self retainCount]);
}
@end
+2
source

Source: https://habr.com/ru/post/1757837/


All Articles