In objective-c when you want to write a class you have to specify the class interface (@interface usually in .h file) and the class implmentation (.m file)
When you want to define an interface that any other class can implement in objective-c thats called a protocol.
@protocol XYZPieChartViewDataSource
- (NSUInteger)numberOfSegments;
- (CGFloat)sizeOfSegmentAtIndex:(NSUInteger)segmentIndex;
@optional
- (NSString *)titleForSegmentAtIndex:(NSUInteger)segmentIndex;
- (BOOL)shouldExplodeSegmentAtIndex:(NSUInteger)segmentIndex;
@required
- (UIColor *)colorForSegmentAtIndex:(NSUInteger)segmentIndex;
@end
Therefore you can write a class that implements this protocol, in order to do this first you have to declare that your class implements this protocol (.h file).
@interface MyClass : NSObject <XYZPieChartViewDataSource>
...
@end
After that you have to write the methods that you want to implement, you must write the required ones and you can write if you need to the optional ones
- (BOOL)shouldExplodeSegmentAtIndex:(NSUInteger)segmentIndex {
// do someting
}
- (UIColor *)colorForSegmentAtIndex:(NSUInteger)segmentIndex {
// do someting
}
As they pointed out you can take a look to the protocol docs: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithProtocols/WorkingwithProtocols.html