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.
精彩评论