Friday, 9 October 2015

How to use Protocol In Ios/iphone

==> Here One Protocol Declared :
@protocol MyProtocol <NSObject>

=> Declared One Of the Method :-

  - (void)aRequiredMethod;

=> Here Required Method:
 @required
- (void)anotherRequiredMethod;

@optional
- (void)anOptionalMethod;

@end

@interface MyClass <MyProtocol>

@end

@property (nonatomic, weak) id<MyProtocol> delegate;

[self.delegate aRequiredMethod];

[self.delegate conformsToProtocol:@protocol(MyProtocol)]

[self.delegate respondsToSelector:@selector(anOptionalMethod)]