tags:

views:

28

answers:

1

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

Does anyone know if there's a proper way to use this directory in a category ?

+1  A: 

Define an interface for the category, just like you would with a class:

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

@implementation NSObject (RetainProperty)
@dynamic moreThanOneRetain;

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