iSekhar
iSekhar

Reputation: 119

Delegate methods in Objective-C and viewcontroller in Swift. How to call protocols? - iOS

I have view controller like in Swift:

class ViewController: UIViewController, DraggableViewDelegate {

(Type viewcontroller does not conform to protocol 'DraggableviewDelegate')

I knew that I have to take protocol methods from delegate class, but it was a in Objective-C like:

#import <UIKit/UIKit.h>
#import "OverlayView.h"

@protocol DraggableViewDelegate <NSObject>

-(void)cardSwipedLeft:(UIView *)card;
-(void)cardSwipedRight:(UIView *)card;

@end

@interface DraggableView : UIView

@property (weak) id <DraggableViewDelegate> delegate;

@property (nonatomic, strong)UIPanGestureRecognizer   *panGestureRecognizer;
@property (nonatomic)CGPoint originalPoint;
@property (nonatomic,strong)OverlayView* overlayView;
@property (nonatomic,strong)UILabel* information; 


-(void)leftClickAction;
-(void)rightClickAction;

@end

Here the methods are in Objective-C:

 -(void)method {}

But in Swift it takes:

func methodName(){}

Upvotes: 2

Views: 1205

Answers (2)

iSekhar
iSekhar

Reputation: 119

Writing like a func card... its taking the delagate methods. like

-(void)cardSwipedLeft:(UIView *)card; as
func cardSwipedLeft.....

Thanks Doro and Dharmesh Kheni for solution and best tuitorial

Upvotes: 0

Related Questions