[英]Declare conformance to objective-c protocol with a category and implement it with another category
clang reports that Test1(FooBar)
doesn't implement foo
or bar
, despite foo being implemented in Test1(Foo)
and bar
being implemented in Test1
. clang报告说Test1(FooBar)
没有实现foo
或bar
,尽管foo在Test1(Foo)
中实现,而bar
在Test1
中实现。 Since Test1(Foo)
's @interface
exists above Test1(FooBar)
's, clang should see that Test1(Foo)
implements foo
and shouldn't require me to implement it in Test1(FooBar)
. 由于Test1(Foo)
的@interface
存在于Test1(FooBar)
之上,因此clang应该看到Test1(Foo)
实现了foo
并且不应该要求我在Test1(FooBar)
实现它。 Since Test1
implements bar
, clang shouldn't require me to implement it in Test1(FooBar)
. 由于Test1
实现了bar
,因此clang不应该要求我在Test1(FooBar)
实现它。
@interface Test1 : NSObject
- (void) bar;
@end
@interface Test1(Foo)
- (void) foo;
@end
@protocol FooBar <NSObject>
- (void) foo;
- (void) bar;
@end
@interface Test1(FooBar)<FooBar>
@end
@implementation Test1(Foo)
- (void) foo {
}
@end
@implementation Test1(FooBar)
@end
My understanding is that this line: 我的理解是这一行:
@interface Test1(FooBar)<FooBar>
can be interpreted in plain english as "The category FooBar on class Test1 should implement protocol FooBar". 可以用简单的英语被解释为“上类测试1 类别 FooBar的应实施协议FooBar的”。 In other words, the protocol applies to the category, not the class. 换句话说,该协议适用于类别,而不是类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.