开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜