嗨,我有它定义了一些ObjC-2.0性质的,像这样的协议:访问协议的属性值?
@protocol Repeatable <NSCoding>
@required
@property (nonatomic, retain) Date *startDate;
@property (nonatomic, retain) Date *endDate;
@end
我有实现协议另一个类:
@interface AbstractRepeatable : NSObject <Repeatable>
最后,在AbstractRepeatable ,我在执行由协议定义的方法:
- (BOOL)isEqualToRepeatable:(Repeatable *)r {
if (r.startDate != startDate) // Compiler error here
return NO;
return YES;
}
星星点点已被排除例如-起见,但编译时,I R在上面提到的那条线上,提出熟悉的“请求会员”startDate“,而不是结构或联盟”。 AbstractRepeatable显然包含可重复标题,否则协议将不可见,所以我不知道我错过了哪个部分。
这个答案可能会清晰一些东西给你:http://stackoverflow.com/questions/844678/how-to-handle-objective-c- protocols-that-contain-properties/844785#844785 – NSSec 2009-09-30 14:34:50
我正在综合AbstractRepeatable中的属性,我无法弄清楚为什么prop没有被识别。 – 2009-09-30 15:29:07