开发者

What does id<Litigating> mean?

开发者_运维知识库

I know "id" type, but what does id<Litigating> mean ?

@protocol Litigating
-(int) sue:( id<Litigating> ) someone;
@end


Think of Objective-C protocols as Java, C#, etc. Interfaces on speed.

This is a variable of any class, conforming to the protocol Litigation (this is as far as traditional OOP goes without jumping hoops):

id<Litigation> someone;

This is a variable of the class Company (and subclasses), that also conforms to Litigation:

Company<Litigation>* someone;

This is a variable of class Company, that also conforms to both Litigation and NSCopying**:

Company<Litigation, NSCopying>* someone;


id<SomeProtocol> 

implies that this object implements SomeProtocol. It must be implementing all the required methods belonging to SomeProtocol.


It means that the parameter is not only of type id but also conforms to the Litigating (formal) protocol, cf. The Objective-C Programming Language.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜