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(){}
1
  • 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. Commented Jun 24, 2015 at 9:03

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.