2

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(){}
iSekhar
  • 119
  • 1
  • 8
  • So what is wrong if it takes `func methodName(){}` in swift and remember objective - c and swift are different language so both have different syntaxes you can use it that way. – Dharmesh Kheni Jun 24 '15 at 09:03

2 Answers2

1

Here is Apple guide for you

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

And here is great answer how to make bridging header

https://stackoverflow.com/a/24005242/2382237

Community
  • 1
  • 1
Doro
  • 2,413
  • 2
  • 14
  • 26
0

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

iSekhar
  • 119
  • 1
  • 8