How to use the @dynamic directive in a Category implementation?
When I try to use开发者_JAVA技巧 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 directive in a category ?
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
精彩评论