Objective-C Language Protocols Conforming to Protocols

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The following syntax indicate that a class adopts a protocol, using angle brackets.

@interface NewClass : NSObject <NewProtocol>
...
@end

This means that any instance of NewClass will respond to methods declared in its interface but also it will provide an implementation for all the required methods of NewProtocol.

It is also possible for a class to conform to multiple protocols, by separating them with comma.

@interface NewClass : NSObject <NewProtocol, AnotherProtocol, MyProtocol>
...
@end

Like when conforming to a single protocol, the class must implement each required method of each protocols, and each optional method you choose to implement.



Got any Objective-C Language Question?