Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does id<Litigating> mean?

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

@protocol Litigating
-(int) sue:( id<Litigating> ) someone;
@end
like image 982
Voloda2 Avatar asked Jun 27 '26 14:06

Voloda2


2 Answers

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;
like image 174
PeyloW Avatar answered Jun 29 '26 06:06

PeyloW


id<SomeProtocol> 

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

like image 43
Akshay Avatar answered Jun 29 '26 07:06

Akshay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!