I am trying to call my Protocol Class in Swift, but its giving me Error
"Type SwiftViewController does not conform to protocol ABCDelegate.
Could you please tell me what I am missing , as I find other posts , but nothing is explained properly , also let me know if you need more info.
@protocol ABCDelegate <NSObject>
@required
- (void) ABC:(NSString*)MessageResponseStr
@end
@interface ABC : NSObject
@property (nonatomic, assign) id<ABCDelegate> delegate;
@property(nonatomic,retain)NSString *ResponseStr;
-(void)Network:(int)NetworkState
A protocol defines abstract behaviour.
Like interface in many other languages. ABCDelegate
protocol simply states: Anything that will implement me, need to specify the following required methods, and can choose to implement the following optional methods.
In your case, your class need to implement the protocol required ABC
method.
When you defined the protocol in ABC
class, you declared the protocol method to be @required
as in -
@protocol ABCDelegate <NSObject>
@required
- (void) ABC:(NSString*)MessageResponseStr
@end
Now in SwiftViewController
or any class that implements the protocol, it has become mandatory to add the - (void) ABC:(NSString*)MessageResponseStr
because of the @required
keyword.
As soon as you implement the method, error will go away.
Hope this helped.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.